| 494 | } |
| 495 | return Result(true); |
| 496 | } |
| 497 | |
| 498 | Result HttpAsyncClient::onResponseBodyStreamRead() |
| 499 | { |
| 500 | if (state == State::StreamingResponse and not response.isBodyComplete()) |
| 501 | { |
| 502 | connection->getReadableTransportStream().resumeReading(); |
| 503 | } |
| 504 | return Result(true); |
| 505 | } |
| 506 | |
| 507 | Result HttpAsyncClient::prepareResponseDecompression() |
| 508 | { |
| 509 | responseDecoderActive = false; |
| 510 | if (responseDecoder == nullptr or response.getBodyFramingKind() == HttpBodyFramingKind::None) |
| 511 | { |
| 512 | return Result(true); |
| 513 | } |
| 514 | |
| 515 | StringSpan contentEncodingHeader; |
| 516 | if (not response.getHeader("Content-Encoding", contentEncodingHeader)) |
| 517 | { |
| 518 | return Result(true); |
| 519 | } |
| 520 | |
| 521 | HttpContentEncoding encoding = HttpContentEncoding::Identity; |
| 522 | SC_TRY(httpContentEncodingFromHeader(contentEncodingHeader, encoding)); |
| 523 | if (encoding == HttpContentEncoding::Identity) |
| 524 | { |
| 525 | return Result(true); |
| 526 | } |
| 527 | |
| 528 | const ZLibStream::Algorithm algorithm = |
| 529 | encoding == HttpContentEncoding::GZip ? ZLibStream::DecompressGZip : ZLibStream::DecompressDeflate; |
| 530 | SC_TRY(responseDecoder->stream.init(algorithm)); |
| 531 | |
| 532 | HttpIncomingMessage::BodyStream& rawBody = response.rawBodyStream(); |
| 533 | SC_TRY_MSG((rawBody.eventData.addListener<HttpAsyncClient, &HttpAsyncClient::onCompressedResponseBodyData>(*this)), |
| 534 | "HttpAsyncClient response decoder data listener limit reached"); |
| 535 | SC_TRY_MSG((rawBody.eventEnd.addListener<HttpAsyncClient, &HttpAsyncClient::onCompressedResponseBodyEnd>(*this)), |
| 536 | "HttpAsyncClient response decoder end listener limit reached"); |
| 537 | SC_TRY_MSG((rawBody.eventError.addListener<HttpAsyncClient, &HttpAsyncClient::onCompressedResponseError>(*this)), |
| 538 | "HttpAsyncClient response decoder raw error listener limit reached"); |
| 539 | SC_TRY_MSG((responseDecoder->AsyncReadableStream::eventError |
| 540 | .addListener<HttpAsyncClient, &HttpAsyncClient::onCompressedResponseError>(*this)), |
| 541 | "HttpAsyncClient response decoder readable error listener limit reached"); |
nothing calls this directly
no test coverage detected