fix: Handle STDIN reads without a body

master
Sean McBride 3 years ago
parent 9c67a84b62
commit f4fdc4a501

@ -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;
}

@ -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;

Loading…
Cancel
Save