diff --git a/runtime/src/http_parser_settings.c b/runtime/src/http_parser_settings.c index 02981f4..0a0adb7 100644 --- a/runtime/src/http_parser_settings.c +++ b/runtime/src/http_parser_settings.c @@ -191,8 +191,13 @@ http_parser_settings_on_header_end(http_parser *parser) debuglog("parser: %p\n", parser); #endif - http_request->header_end = true; - http_request->body_length = parser->content_length; + http_request->header_end = true; + + if (parser->method == HTTP_PUT || parser->method == HTTP_POST) { + http_request->body_length = parser->content_length; + } else { + http_request->body_length = 0; + } return 0; } diff --git a/runtime/src/libc/wasi_impl_serverless.c b/runtime/src/libc/wasi_impl_serverless.c index eb37867..2c995e1 100644 --- a/runtime/src/libc/wasi_impl_serverless.c +++ b/runtime/src/libc/wasi_impl_serverless.c @@ -663,6 +663,8 @@ wasi_snapshot_preview1_backing_fd_read(wasi_context_t *context, __wasi_fd_t fd, int old_read = current_request->cursor; int bytes_to_read = current_request->body_length - old_read; + assert(current_request->body_length >= 0); + for (int i = 0; i < iovs_len; i++) { if (bytes_to_read == 0) goto done;