Skip to content

Content-Type: application/json; charset=utf-8 can cause issues and may be incorrect #528

Description

@jbrechtel

setRequestBodyJSON appends a "; charset=utf-8" to the end of the Content-Type header and this causes some libraries like

https://hc.apache.org/httpcomponents-core-4.4.x/current/httpcore/apidocs/org/apache/http/entity/ContentType.html

to fail to parse such HTTP requests.

It seems like the charset parameter is at best redundant (since JSON must be UTF-8) and at worst incorrect entirely according to the RFC - see the conversation here https://stackoverflow.com/questions/9254891/what-does-content-type-application-json-charset-utf-8-really-mean

I suggest removing it entirely from setRequestBodyJSON and only set Content-Type to application/json. If that's OK then I'm happy to submit a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions