| 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 | { |