Skip to content

Commit 4930635

Browse files
authored
Merge pull request #22 from anthonyroux/android_verb
Fix Issue #21 - HTTPURLConnection not working well on Android
2 parents 709c7d5 + 6f0e549 commit 4930635

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/java/com/amadeus/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public final class Constants {
1111
// HTTP verbs
1212
public static final String GET = "GET";
1313
public static final String POST = "POST";
14+
public static final String PUT = "PUT";
15+
1416

1517
public static final String HTTPS = "https";
1618
public static final String HTTP = "http";

src/main/java/com/amadeus/Request.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ protected void establishConnection() throws IOException {
106106
this.connection = (HttpURLConnection) new URL(uri).openConnection();
107107
connection.setRequestMethod(verb);
108108
connection.setDoInput(true);
109-
connection.setDoOutput(true);
109+
if (verb == Constants.POST || verb == Constants.PUT) {
110+
connection.setDoOutput(true);
111+
}
110112
for (Map.Entry<String, String> entry : headers.entrySet()) {
111113
connection.setRequestProperty(entry.getKey(), entry.getValue());
112114
}

0 commit comments

Comments
 (0)