| 60 | } |
| 61 | |
| 62 | std::pair<std::shared_ptr<std::ostream>, std::shared_ptr<std::ostream>> HTTPServerResponse::beginSend() |
| 63 | { |
| 64 | poco_assert(!stream); |
| 65 | poco_assert(!header_stream); |
| 66 | |
| 67 | /// NOTE: Code is not exception safe. |
| 68 | |
| 69 | if ((request && request->getMethod() == HTTPRequest::HTTP_HEAD) || getStatus() < 200 || getStatus() == HTTPResponse::HTTP_NO_CONTENT |
| 70 | || getStatus() == HTTPResponse::HTTP_NOT_MODIFIED) |
| 71 | { |
| 72 | throw Poco::Exception("HTTPServerResponse::beginSend is invalid for HEAD request"); |
| 73 | } |
| 74 | else if (getChunkedTransferEncoding()) |
| 75 | { |
| 76 | header_stream = std::make_shared<Poco::Net::HTTPHeaderOutputStream>(session); |
| 77 | beginWrite(*header_stream); |
| 78 | stream = std::make_shared<Poco::Net::HTTPChunkedOutputStream>(session); |
| 79 | } |
| 80 | else if (hasContentLength()) |
| 81 | { |
| 82 | throw Poco::Exception("HTTPServerResponse::beginSend is invalid for response with Content-Length header"); |
| 83 | } |
| 84 | else |
| 85 | { |
| 86 | stream = std::make_shared<Poco::Net::HTTPOutputStream>(session); |
| 87 | header_stream = stream; |
| 88 | setKeepAlive(false); |
| 89 | beginWrite(*stream); |
| 90 | } |
| 91 | |
| 92 | return std::make_pair(header_stream, stream); |
| 93 | } |
| 94 | |
| 95 | void HTTPServerResponse::sendBuffer(const void * buffer, std::size_t length) |
| 96 | { |
no test coverage detected