MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / prepareRequest

Method prepareRequest

src/IO/ReadWriteBufferFromHTTP.cpp:100–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void ReadWriteBufferFromHTTP::prepareRequest(Poco::Net::HTTPRequest & request, std::optional<HTTPRange> range) const
101{
102 if (current_uri.getPort())
103 request.setHost(current_uri.getHost(), current_uri.getPort());
104 else
105 request.setHost(current_uri.getHost());
106
107 if (out_stream_callback)
108 request.setChunkedTransferEncoding(true);
109 else if (method == Poco::Net::HTTPRequest::HTTP_POST)
110 request.setContentLength(0); /// No callback - no body
111
112 for (const auto & [header, value] : http_header_entries)
113 request.set(header, value);
114
115 if (range)
116 {
117 String range_header_value;
118 if (range->end)
119 range_header_value = fmt::format("bytes={}-{}", *range->begin, *range->end);
120 else
121 range_header_value = fmt::format("bytes={}-", *range->begin);
122 request.set("Range", range_header_value);
123 }
124
125 if (!credentials.getUsername().empty())
126 credentials.authenticate(request);
127}
128
129std::optional<size_t> ReadWriteBufferFromHTTP::tryGetFileSize()
130{

Callers

nothing calls this directly

Calls 9

getHostMethod · 0.80
setContentLengthMethod · 0.80
formatFunction · 0.50
getPortMethod · 0.45
setHostMethod · 0.45
setMethod · 0.45
emptyMethod · 0.45
authenticateMethod · 0.45

Tested by

no test coverage detected