Skip to content

Commit

Permalink
Add missing api::url::URLSearchParams in Body::Initializer.
Browse files Browse the repository at this point in the history
Co-authored-by: James M Snell <[email protected]>
Signed-off-by: Jianyong Chen <[email protected]>
  • Loading branch information
2 people authored and fhanau committed Dec 2, 2024
1 parent a27a73a commit e07508e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/workerd/api/http.c++
Original file line number Diff line number Diff line change
Expand Up @@ -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<url::URLSearchParams>) {
auto type = MimeType::FORM_URLENCODED.clone();
type.addParam("charset"_kj, "UTF-8"_kj);
contentType = type.toString();
buffer = searchParams->toString();
}
}

auto bodyStream = kj::heap<BodyBufferInputStream>(buffer.clone(js));
Expand Down
4 changes: 3 additions & 1 deletion src/workerd/api/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "form-data.h"
#include "web-socket.h"
#include <workerd/api/url.h>
#include <workerd/api/url-standard.h>
#include "blob.h"
#include <workerd/io/compatibility-date.capnp.h>
#include "worker-rpc.h"
Expand Down Expand Up @@ -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<jsg::Ref<ReadableStream>, kj::String, kj::Array<byte>,
jsg::Ref<Blob>, jsg::Ref<URLSearchParams>, jsg::Ref<FormData>>;
jsg::Ref<Blob>, jsg::Ref<FormData>,
jsg::Ref<URLSearchParams>, jsg::Ref<url::URLSearchParams>>;

struct RefcountedBytes final: public kj::Refcounted {
kj::Array<kj::byte> bytes;
Expand Down

0 comments on commit e07508e

Please sign in to comment.