-
Notifications
You must be signed in to change notification settings - Fork 54
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
fix: Use UTF-8 as default charset for HttpJson requests #1477
Conversation
Thanks Lawrence! This is a perfect example that showcase can help us identify bugs in our implementation, cc @burkedavison @mpeddada1 |
@@ -172,7 +172,7 @@ HttpRequest createHttpRequest() throws IOException { | |||
jsonFactory.createJsonParser(requestBody).parse(tokenRequest); | |||
jsonHttpContent = | |||
new JsonHttpContent(jsonFactory, tokenRequest) | |||
.setMediaType((new HttpMediaType("application/json"))); | |||
.setMediaType((new HttpMediaType("application/json; charset=utf-8"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good to me! This makes me think though, we are currently hardcoding all content type to application/json
, which is fine for now, but it will not work for services like storage in the future. It might be one of the reasons that storage has been a handwritten library. CC @meltsufin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my curiosity: What content-type does Storage use? Wondering if it's as easy as setting the charset or having to create/ modify the HttpMediaType class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on the use case, in their example, it is set to text/plain
. We probably need to make it a parameter in the future and set it differently based on the scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll create an issue to track this. Might be something that a future GAPIC library needs. Also, don't the handwritten libraries use java-core instead of gax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They use both, also we are thinking about reducing the need of handwritten libraries(including java-core), so this could be one of places. I wouldn't create an issue yet as we don't have the need yet, but something to keep in mind.
gax-java/gax-httpjson/src/test/java/com/google/api/gax/httpjson/HttpRequestRunnableTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…ase and gax modules (#1430) * chore: add aggregate test coverage collection for showcase and gax
* feat: install clirr check * install an independent action * format changes * change name * change action name
[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed! |
) Thank you for opening a Pull Request! For general contributing guidelines, please refer to [contributing guide](https://togithub.com/googleapis/gapic-generator-java/blob/main/CONTRIBUTING.md) Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/gapic-generator-java/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes googleapis#1437
) Thank you for opening a Pull Request! For general contributing guidelines, please refer to [contributing guide](https://togithub.com/googleapis/gapic-generator-java/blob/main/CONTRIBUTING.md) Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/gapic-generator-java/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) Fixes googleapis#1437
Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #1437