Open nickbabcock opened 2 weeks ago
export default { async fetch(request, env, ctx) { const r = new Request('https://example.com/', { method: 'POST', body: new URLSearchParams({ hello: 'world' }) }); return new Response(r.headers.get('content-type')) }, };
Expected (ref):
application/x-www-form-urlencoded;charset=UTF-8
Actual:
text/plain;charset=UTF-8
This behavior differs from browsers and node.js
Replicated in cloudflare workers playground and in a production workers deployment.
It seems that api::url::URLSearchParams instead of api::URLSearchParams should be used in Body::Initializer:
api::url::URLSearchParams
api::URLSearchParams
Body::Initializer
https://github.com/cloudflare/workerd/blob/f32706b15ea3daa0e13a097d25d259d6ccf942be/src/workerd/api/http.h#L255
Expected (ref):
Actual:
This behavior differs from browsers and node.js
Replicated in cloudflare workers playground and in a production workers deployment.