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

Bug in Android #21

Closed
vht210 opened this issue Jan 28, 2019 · 2 comments
Closed

Bug in Android #21

vht210 opened this issue Jan 28, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@vht210
Copy link

vht210 commented Jan 28, 2019

Description

When I try to use the library in Android App. I have noticed that it always send POST request instead of GET request.
The reason is under com.amadeus/Request.java you have
protected void establishConnection() throws IOException {
this.connection = (HttpURLConnection) new URL(uri).openConnection();
connection.setRequestMethod(verb);
connection.setDoInput(true);
connection.setDoOutput(true);

So no matter setRequestMethod is, when setDoOutput=true, it always POST

According to https://developer.android.com/reference/java/net/HttpURLConnection
HTTP Methods
HttpURLConnection uses the GET method by default. It will use POST if setDoOutput(true) has been called. Other HTTP methods (OPTIONS, HEAD, PUT, DELETE and TRACE) can be used with setRequestMethod(String).

Suggestion fix:
connection.setDoOuput(true) only when the verb is POST

@anthonyroux
Copy link
Contributor

I've been able to reproduce, added to our backlog to fix it.

Thank you very much!

@anthonyroux anthonyroux added the bug Something isn't working label Jan 28, 2019
anthonyroux pushed a commit to anthonyroux/amadeus-java that referenced this issue Jan 28, 2019
anthonyroux added a commit that referenced this issue Jan 28, 2019
Fix Issue #21 - HTTPURLConnection not working well on Android
@anthonyroux
Copy link
Contributor

anthonyroux commented Jan 28, 2019

I published the fix under the version 3.0.1.
It has been released on Bintray, it always takes longer to have it available on JCenter.

Thanks a lot for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants