| Summary: | Fetch POST Requests Not Working on Safari | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Pranay Yadav <pranayyadav08> |
| Component: | Page Loading | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Blocker | CC: | achristensen, ap, beidson, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 16 | ||
| Hardware: | All | ||
| OS: | iOS 16 | ||
|
Description
Pranay Yadav
2023-03-15 22:37:13 PDT
Could you please provide some of the examples that don't work? This is very basic functionality, it's fairly unlikely that the issue is so general. There must be some specific detail that triggers the issue. the following snipped of code is used to make the request :
fetch(REQUEST_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: '{"get_response": true}',
})
but the request received on the backend is :
"POST / HTTP/1.1\r\nHost: localhost:60145\r\nContent-Type: application/json\r\nOrigin: http://localhost:60145\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nAccept: application/json\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15\r\nReferer: http://localhost:60145/\r\nContent-Length: 22\r\nAccept-Language: en-IN,en-GB;q=0.9,en;q=0.8\r\n\r\n"
and after 300+ requests, the body was finally added and the request received on backend was :
"POST / HTTP/1.1\r\nHost: localhost:60145\r\nContent-Type: application/json\r\nOrigin: http://localhost:60145\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive\r\nAccept: application/json\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15\r\nReferer: http://localhost:60145/\r\nContent-Length: 22\r\nAccept-Language: en-IN,en-GB;q=0.9,en;q=0.8\r\n\r\n{\"get_response\": true}"
So this isn't even a cross-origin request, both are localhost:60145 for you. I cannot reproduce this with these steps: - Put fetch.html (below) in LayoutTests/http/tests in a WebKit checkout. - run-webkit-httpd - load http://127.0.0.1:8000/fetch.html in Safari - terminate run-webkit-httpd - nc -l 8000 - Click the Test button on the page. I always get the request body in nc output. ----- fetch.html <button onclick="test()">Test</button> <script> function test() { fetch("http://127.0.0.1:8000/", { method: "POST", headers: { "Content-Type": "application/json", "Accept": "application/json", }, body: '{"get_response": true}', }) } </script> |