amphp / http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

Home Page:https://amphp.org/http-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong content type in JsonBody

PhantomArt opened this issue · comments

commented

When using Amp\Http\Client\Body\JsonBody, the content type is set to application/json; charset=utf-8 when application/json should be used. I noticed it by accident. Here this discussion might be helpful: https://stackoverflow.com/questions/9254891/what-does-content-type-application-json-charset-utf-8-really-mean

It might not be necessary, but why should it be wrong?

commented

Specifying charset for JSON is redundant because JSON assumes Unicode character encoding. Perhaps this is not a bug, but an overstatement. Personally, my experience is that the content type for JSON never contains a charset. A few years ago, I ran into an issue where the other side wouldn't accept my JSON when I specified a charset. I have since learned that the correct content type for JSON is application/json.