Skip to content

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

@jbrechtel

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.

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