diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index 253936c00a..281426dd3e 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -53,6 +53,7 @@ import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; +import static java.util.Arrays.asList; import static org.kohsuke.github.GitHub.*; /** @@ -61,6 +62,8 @@ * @author Kohsuke Kawaguchi */ class Requester { + private static final List METHODS_WITHOUT_BODY = asList("GET", "DELETE"); + private final GitHub root; private final List args = new ArrayList(); private final Map headers = new LinkedHashMap(); @@ -208,7 +211,7 @@ public T to(String tailApiUrl, Class type, String method) throws IOExcept private T _to(String tailApiUrl, Class type, T instance) throws IOException { while (true) {// loop while API rate limit is hit - if (method.equals("GET") && !args.isEmpty()) { + if (METHODS_WITHOUT_BODY.contains(method) && !args.isEmpty()) { StringBuilder qs=new StringBuilder(); for (Entry arg : args) { qs.append(qs.length()==0 ? '?' : '&'); @@ -296,6 +299,7 @@ private void buildRequest() throws IOException { for (Entry e : args) { json.put(e.key, e.value); } + MAPPER.writeValue(uc.getOutputStream(), json); } else { try { byte[] bytes = new byte[32768]; @@ -311,9 +315,7 @@ private void buildRequest() throws IOException { } private boolean isMethodWithBody() { - if (method.equals("GET")) return false; - if (method.equals("DELETE")) return false; - return true; + return !METHODS_WITHOUT_BODY.contains(method); } /**