diff --git a/src/workerd/api/http.c++ b/src/workerd/api/http.c++ index 7555aa80506..c5cc67aa7fd 100644 --- a/src/workerd/api/http.c++ +++ b/src/workerd/api/http.c++ @@ -704,6 +704,12 @@ Body::ExtractedBody Body::extractBody(jsg::Lock& js, Initializer init) { contentType = type.toString(); buffer = searchParams->toString(); } + KJ_CASE_ONEOF(searchParams, jsg::Ref) { + auto type = MimeType::FORM_URLENCODED.clone(); + type.addParam("charset"_kj, "UTF-8"_kj); + contentType = type.toString(); + buffer = searchParams->toString(); + } } auto bodyStream = kj::heap(buffer.clone(js)); diff --git a/src/workerd/api/http.h b/src/workerd/api/http.h index b1d90f8b8fc..ee3672b195f 100644 --- a/src/workerd/api/http.h +++ b/src/workerd/api/http.h @@ -14,6 +14,7 @@ #include "form-data.h" #include "web-socket.h" #include +#include #include "blob.h" #include #include "worker-rpc.h" @@ -252,7 +253,8 @@ class Body: public jsg::Object { // from any of the other source types, Body can create a new ReadableStream from the source, and // the POST will successfully retransmit. using Initializer = kj::OneOf, kj::String, kj::Array, - jsg::Ref, jsg::Ref, jsg::Ref>; + jsg::Ref, jsg::Ref, + jsg::Ref, jsg::Ref>; struct RefcountedBytes final: public kj::Refcounted { kj::Array bytes;