Sending progress in HTTP headers (continued) [#CLICKHOUSE-32].

This commit is contained in:
Alexey Milovidov 2017-01-22 18:48:53 +03:00
parent b2457e076a
commit 3476e4d4c4
4 changed files with 6 additions and 7 deletions

View File

@ -67,7 +67,7 @@ public:
/// Must not be called after beginSend(), sendFile(), sendBuffer()
/// or redirect() has been called.
virtual void beginSend(std::ostream * out_header_stream, std::ostream * out_body_stream) = 0;
virtual std::pair<std::ostream *, std::ostream *> beginSend() = 0;
/// Sends the response headers to the client
/// but do not finish headers with \r\n,
/// allowing to continue sending additional header fields.

View File

@ -65,7 +65,7 @@ public:
/// Must not be called after beginSend(), sendFile(), sendBuffer()
/// or redirect() has been called.
void beginSend(std::ostream * out_header_stream, std::ostream * out_body_stream);
std::pair<std::ostream *, std::ostream *> beginSend();
/// Sends the response headers to the client
/// but do not finish headers with \r\n,
/// allowing to continue sending additional header fields.

View File

@ -111,7 +111,7 @@ std::ostream& HTTPServerResponseImpl::send()
}
void HTTPServerResponseImpl::beginSend(std::ostream * out_header_stream, std::ostream * out_body_stream)
std::pair<std::ostream *, std::ostream *> HTTPServerResponseImpl::beginSend()
{
poco_assert (!_pStream);
poco_assert (!_pHeaderStream);
@ -141,8 +141,7 @@ void HTTPServerResponseImpl::beginSend(std::ostream * out_header_stream, std::os
beginWrite(*_pStream);
}
out_header_stream = _pHeaderStream;
out_body_stream = _pStream;
return std::make_pair(out_header_stream, out_body_stream);
}

View File

@ -82,7 +82,7 @@ private:
throw Exception("Logical error: unknown compression method passed to WriteBufferFromHTTPServerResponse",
ErrorCodes::LOGICAL_ERROR);
response.beginSend(response_header_ostr, response_body_ostr);
std::tie(response_header_ostr, response_body_ostr) = response.beginSend();
out_raw.emplace(*response_body_ostr);
/// Use memory allocated for the outer buffer in the buffer pointed to by out. This avoids extra allocation and copy.
deflating_buf.emplace(out_raw.value(), compression_method, compression_level, working_buffer.size(), working_buffer.begin());
@ -90,7 +90,7 @@ private:
}
else
{
response.beginSend(response_header_ostr, response_body_ostr);
std::tie(response_header_ostr, response_body_ostr) = response.beginSend();
out_raw.emplace(*response_body_ostr, working_buffer.size(), working_buffer.begin());
out = &out_raw.value();
}