| 81 | } |
| 82 | |
| 83 | void 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 | |
| 113 | void StaticRequestHandler::writeResponse(WriteBuffer & out) |
| 114 | { |
nothing calls this directly
no test coverage detected