-
Notifications
You must be signed in to change notification settings - Fork 202
fetch: GET sends "null" body #660
Copy link
Copy link
Closed
Description
Build from current master, 'make test' reports no errors.
> await fetch('http://localhost:9999')
// second shell
$ nc -l -p 9999
GET / HTTP/1.1
Host: localhost:9999
User-Agent: txiki.js/24.6.0
Accept: */*
Content-Length: 4
Content-Type: application/x-www-form-urlencoded
null
Some servers don't like this (e.g. google.com) and respond with 400.
> await fetch('http://localhost:9999', {method: 'GET'})
// as above, same as {method: 'GET', body: null}
> await fetch('http://localhost:9999', {method: 'HEAD'})
HEAD / HTTP/1.1
Host: localhost:9999
User-Agent: txiki.js/24.6.0
Accept: */*
> await fetch('http://localhost:9999', {method: 'GET', body: ''})
GET / HTTP/1.1
Host: localhost:9999
User-Agent: txiki.js/24.6.0
Accept: */*
content-type: text/plain;charset=UTF-8
Content-Length: 0
not sure where exactly it goes wrong; note: 'content-type' vs 'Content-Type'. maybe the latter is the curl default.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels