okhttp
okhttp copied to clipboard
incorrect JSON media type in example
https://github.com/square/okhttp#post-to-a-server says:
public static final MediaType JSON
= MediaType.get("application/json; charset=utf-8");
But application/json does not define a charset parameter.
It's not clear it's an error rather than just redundant
https://www.iana.org/assignments/media-types/application/json
Note: No "charset" parameter is defined for this registration. Adding one really has no effect on compliant recipients.
Same in https://www.rfc-editor.org/rfc/rfc8259
To make this change, it would have to be in the docs but also the code, since we resolve the charset
https://github.com/square/okhttp/blob/34d5cba5a889b8219d997fbb4153ddb4a5e51319/okhttp/src/jvmMain/kotlin/okhttp3/internal/internal.kt#L61
I suspect we don't want to implement all possible mime type conventions.
Well, having that example is minimally misleading. It implies that you could have something other than UTF-8, and that would have an effect which in general is not true.
Sure, if you want to submit a PR to fix the doc, then happy to simplify the example.
Here is the PR with the fix, please review -> https://github.com/square/okhttp/pull/7494