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

Method handleRequest

src/Server/StaticRequestHandler.cpp:83–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83void StaticRequestHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse & response, const ProfileEvents::Event & /*write_event*/)
84{
85 applyHTTPResponseHeaders(response, http_response_headers_override);
86
87 if (request.getVersion() == Poco::Net::HTTPServerRequest::HTTP_1_1)
88 response.setChunkedTransferEncoding(true);
89
90 auto response_output = responseWriteBuffer(request, response);
91
92 try
93 {
94 /// Workaround. Poco does not detect 411 Length Required case.
95 if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST && !request.getChunkedTransferEncoding() && !request.hasContentLength())
96 throw Exception(ErrorCodes::HTTP_LENGTH_REQUIRED,
97 "The Transfer-Encoding is not chunked and there "
98 "is no Content-Length header for POST request");
99
100 setResponseDefaultHeaders(response);
101 response.setStatusAndReason(Poco::Net::HTTPResponse::HTTPStatus(status));
102 writeResponse(*response_output.get());
103 response_output.get()->finalize();
104 }
105 catch (...)
106 {
107 tryLogCurrentException("StaticRequestHandler");
108 response_output.response_holder->cancelWithException(
109 request, getCurrentExceptionCode(), getCurrentExceptionMessage(false, true), response_output.compression_holder.get());
110 }
111}
112
113void StaticRequestHandler::writeResponse(WriteBuffer & out)
114{

Callers

nothing calls this directly

Calls 15

applyHTTPResponseHeadersFunction · 0.85
responseWriteBufferFunction · 0.85
HTTPStatusEnum · 0.85
getCurrentExceptionCodeFunction · 0.85
hasContentLengthMethod · 0.80
setStatusAndReasonMethod · 0.80
cancelWithExceptionMethod · 0.80
ExceptionClass · 0.50

Tested by

no test coverage detected