Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request charset defaults to UTF-8, Response charset defaults to ISO_8859_1 #300

Closed
edatkinvey opened this issue Sep 11, 2015 · 1 comment
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@edatkinvey
Copy link

Both the request and response objects should default to the same charsets. This causes very hard to troubleshoot bugs with repeated requests.

from com.google.api.client.http.HttpResponse

public Charset getContentCharset() {
    return mediaType == null || mediaType.getCharsetParameter() == null
        ? Charsets.ISO_8859_1 : mediaType.getCharsetParameter();
}

from com.google.api.client.http.AbstractHttpContent

protected final Charset getCharset() {
    return mediaType == null || mediaType.getCharsetParameter() == null
        ? Charsets.UTF_8 : mediaType.getCharsetParameter();
}

Ideally both will use Charsets.UTF_8, as Charsets.ISO_8859_1 only supports a subset.

@elharo
Copy link
Contributor

elharo commented Jan 25, 2017

Per the HTTP 1.1 spec, if the server does not supply a charset in the HTTP headers, then ISO-8859-1 is assumed. Thus on the request, I think we should return Charsets.8859_1 instead of Charsets.UTF_8.

When sending, we can specify anything we like as long as we include the right header, and it's certainly better to include than not.

@ejona86 ejona86 added the type: question Request for information or clarification. Not an issue. label Feb 22, 2017
ajaaym added a commit to ajaaym/google-http-java-client that referenced this issue Dec 4, 2018
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants