Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 24b2504818089f0c82eb3c4e3a235a6805464194
https://github.com/WebKit/WebKit/commit/24b2504818089f0c82eb3c4e3a235a6805464194
Author: Ahmad Saleem <[email protected]>
Date: 2026-08-02 (Sun, 02 Aug 2026)
Changed paths:
M LayoutTests/imported/w3c/web-platform-tests/xhr/send-usp.any-expected.txt
M LayoutTests/imported/w3c/web-platform-tests/xhr/send-usp.any.js
M
LayoutTests/imported/w3c/web-platform-tests/xhr/send-usp.any.worker-expected.txt
M Source/WebCore/xml/XMLHttpRequest.cpp
M Source/WebCore/xml/XMLHttpRequest.h
Log Message:
-----------
XMLHttpRequest.send(URLSearchParams) sets a Content-Type request header on
GET and HEAD requests
https://bugs.webkit.org/show_bug.cgi?id=320791
rdar://183801778
Reviewed by Chris Dumez.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
send(URLSearchParams) set `Content-Type:
application/x-www-form-urlencoded;charset=UTF-8`
before doing anything else, and without the `m_method != GET/HEAD` check that
every
sibling send() overload has. Per step 3 of the send() algorithm the body is set
to null
for GET and HEAD, so step 4 — which is what sets Content-Type — never runs for
those
methods. We sent the header on a request that carries no body, which Blink and
Gecko
both get right.
Setting the header ahead of prepareToSend() also meant it was set even when
send()
went on to throw InvalidStateError or hit a CSP failure.
Route send(URLSearchParams) through prepareToSend() first and then through a new
sendStringData() helper factored out of send(String&&), so both
string-serialized
bodies share one copy of the method guard, the author-supplied Content-Type
charset
reconciliation, and the m_upload streaming path. Only the default MIME type
differs.
Extends the imported send-usp.any.js with Content-Type and request-body
coverage for
POST (with and without an author-set Content-Type), GET and HEAD; previously it
only
covered POST. The charset-reconciliation subtest asserts what Blink, Gecko and
WebKit
all do rather than what the spec literally says, since the spec restricts that
step to
Document and string bodies but no engine implements it that way.
* LayoutTests/imported/w3c/web-platform-tests/xhr/send-usp.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/xhr/send-usp.any.js:
(x.send):
(forEach):
*
LayoutTests/imported/w3c/web-platform-tests/xhr/send-usp.any.worker-expected.txt:
* Source/WebCore/xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):
(WebCore::XMLHttpRequest::sendStringData):
* Source/WebCore/xml/XMLHttpRequest.h:
Canonical link: https://commits.webkit.org/318424@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications