| 1056 | } |
| 1057 | |
| 1058 | static int on_message_complete(http_parser* p) |
| 1059 | { |
| 1060 | StreamingRequestDecoder* decoder = (StreamingRequestDecoder*) p->data; |
| 1061 | |
| 1062 | // This can happen if the callback `on_headers_complete()` had failed |
| 1063 | // earlier (e.g., due to invalid query parameters). |
| 1064 | if (decoder->writer.isNone()) { |
| 1065 | CHECK(decoder->failure); |
| 1066 | return http_parsing::FAILURE; |
| 1067 | } |
| 1068 | |
| 1069 | http::Pipe::Writer writer = decoder->writer.get(); // Remove const. |
| 1070 | |
| 1071 | if (decoder->decompressor.get() != nullptr && |
| 1072 | !decoder->decompressor->finished()) { |
| 1073 | writer.fail("Failed to decompress body"); |
| 1074 | decoder->failure = true; |
| 1075 | return http_parsing::FAILURE; |
| 1076 | } |
| 1077 | |
| 1078 | writer.close(); |
| 1079 | |
| 1080 | decoder->writer = None(); |
| 1081 | |
| 1082 | return http_parsing::SUCCESS; |
| 1083 | } |
| 1084 | |
| 1085 | bool failure; |
| 1086 | |