Reputation: 8858
I have created a javascript library and I am setting manually the Content-Type right now. I would love to know what is the default Content-Type. The XHR documentation for the send() method is confusing at best:
4. If body is null, go to the next step. Otherwise ...
BodyInit
If body is a string, set encoding to
UTF-8
.Set request body and Content-Type to the result of extracting body.
Where, the result of extracting body for a text is:
So, which of these types would it be? The body
passed to send()
is in the default, escaped format of a=b&c=d
. Is it a URLSearchParams
? or a USVString
? or a Blob
? There's a description on each one but it's too cryptic for me to understand (I only know that it's probably not a FormData).
Note: please provide some official documentation if possible
Upvotes: 5
Views: 3955
Reputation: 15144
Directly from the horse's mouth, if you are sending a string their last test expects "text/plain;charset=UTF-8"
in accordance with the XMLHttpRequest Level 1 specification.
So you will have to refer to the step four of the send method to know exactly what is expected depending on the data.
Upvotes: 3