MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / setCompressedBody

Method setCompressedBody

Libraries/Http/HttpConnection.cpp:1306–1325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304}
1305
1306Result 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
1327void HttpAsyncClientRequest::setMultipart(HttpMultipartWriter& value)
1328{

Callers 1

onPrepareMethod · 0.80

Calls 2

httpContentEncodingNameFunction · 0.85
initMethod · 0.45

Tested by 1

onPrepareMethod · 0.64