| 1304 | } |
| 1305 | |
| 1306 | Result HttpAsyncClientRequest::setCompressedBody(AsyncReadableStream& stream, SyncZLibTransformStream& compressor, |
| 1307 | HttpContentEncoding encoding) |
| 1308 | { |
| 1309 | SC_TRY_MSG(encoding == HttpContentEncoding::GZip or encoding == HttpContentEncoding::Deflate, |
| 1310 | "HttpAsyncClientRequest compressed body requires gzip or deflate"); |
| 1311 | |
| 1312 | bodyType = BodyType::Stream; |
| 1313 | bodySpan = {}; |
| 1314 | bodyStream = &stream; |
| 1315 | bodyTransform = &compressor; |
| 1316 | contentLength = 0; |
| 1317 | contentEncoding = encoding; |
| 1318 | multipartWriter = nullptr; |
| 1319 | |
| 1320 | const ZLibStream::Algorithm algorithm = |
| 1321 | encoding == HttpContentEncoding::GZip ? ZLibStream::CompressGZip : ZLibStream::CompressDeflate; |
| 1322 | SC_TRY(compressor.stream.init(algorithm)); |
| 1323 | SC_TRY(HttpOutgoingMessage::addHeader("Content-Encoding", httpContentEncodingName(encoding))); |
| 1324 | return setChunkedTransferEncoding(); |
| 1325 | } |
| 1326 | |
| 1327 | void HttpAsyncClientRequest::setMultipart(HttpMultipartWriter& value) |
| 1328 | { |