MCPcopy Create free account
hub / github.com/3rdparty/libprocess / on_body

Method on_body

src/decoder.hpp:1030–1056  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1028 }
1029
1030 static int on_body(http_parser* p, const char* data, size_t length)
1031 {
1032 StreamingRequestDecoder* decoder = (StreamingRequestDecoder*) p->data;
1033
1034 CHECK_SOME(decoder->writer);
1035
1036 http::Pipe::Writer writer = decoder->writer.get(); // Remove const.
1037
1038 std::string body;
1039 if (decoder->decompressor.get() != nullptr) {
1040 Try<std::string> decompressed =
1041 decoder->decompressor->decompress(std::string(data, length));
1042
1043 if (decompressed.isError()) {
1044 decoder->failure = true;
1045 return http_parsing::FAILURE;
1046 }
1047
1048 body = std::move(decompressed.get());
1049 } else {
1050 body = std::string(data, length);
1051 }
1052
1053 writer.write(std::move(body));
1054
1055 return http_parsing::SUCCESS;
1056 }
1057
1058 static int on_message_complete(http_parser* p)
1059 {

Callers

nothing calls this directly

Calls 2

writeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected