From dbc79f8c423749311495cb548c1a9cda1d8638cf Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Tue, 1 Mar 2016 19:46:50 -0800 Subject: [PATCH] Fixing issue raised in https://github.com/kohsuke/github-api/pull/247 From Shredder121, -------------------- Only the HttpURLConnection.method was set by that change. Not the Requester.method. This means that Requester.method is still set to POST, isMethodWithBody will return true, and uc.setDoOutput(true) will be called. I use Okhttp, and their HttpURLConnectionImpl's method changes to POST if you tell it to open a stream to write to. --- src/main/java/org/kohsuke/github/Requester.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index c9835677ea..af4819c3a1 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -264,10 +264,9 @@ private T _to(String tailApiUrl, Class type, T instance) throws IOExcepti */ public int asHttpStatusCode(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit + method("GET"); setupConnection(root.getApiURL(tailApiUrl)); - uc.setRequestMethod("GET"); - buildRequest(); try { @@ -280,12 +279,10 @@ public int asHttpStatusCode(String tailApiUrl) throws IOException { public InputStream asStream(String tailApiUrl) throws IOException { while (true) {// loop while API rate limit is hit + method("GET"); // if the download link is encoded with a token on the query string, the default behavior of POST will fail setupConnection(root.getApiURL(tailApiUrl)); - // if the download link is encoded with a token on the query string, the default behavior of POST will fail - uc.setRequestMethod("GET"); - - buildRequest(); + buildRequest(); try { return wrapStream(uc.getInputStream());