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

bugfix/set character set on output stream writer to UTF 8 #15

Conversation

srt4
Copy link

@srt4 srt4 commented Jan 30, 2018

The existing HTTP client from cc.protea uses an OutputStreamWriter with the one-argument constructer, leading it to accept the system default character set.

This presents issues as Hyperwallet accepts a certain character set, but does not know which characters the client's host OS supports by default.

The change sets the character set to UTF-8, which is in accordance with Hyperwallet specifications.

n.b. I highly recommend that Hyperwallet migrates away from using the cc.protea HTTP library. The library is useful in that it's syntactic sugar for HttpURLConnection, but past that it's detrimental in terms of debuggability. I opened another pull request that also overrides a cc.protea class - and most of the functionality provided by the cc.protea library would be replicated by allowing the HyperwalletApiClient class to accept an HttpClient parameter.

connection.setDoOutput(true);
connection.setRequestMethod(method);

writer = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
Copy link
Author

@srt4 srt4 Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the significant change. It calls the constructor with two parameters (previously it was just writer = new OutputStreamWriter(connection.getOutputStream());) - the second being the character set to support, overriding the system default (which shouldn't be used in an SDK).

/**
* This class represents an HTTP Request message.
*/
public class Utf8Request extends Message<Utf8Request> {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class name is updated so that we can still import the cc.protea library while avoiding contentious class-loading cardinality issues.

@gmeyer-hw gmeyer-hw force-pushed the master branch 3 times, most recently from 155ac7b to e646a8f Compare October 10, 2018 03:59
@grmeyer-hw-dev
Copy link
Collaborator

Hi @srt4,

Thanks for you contributing.
Do you still need this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants