6060import static java .util .Arrays .asList ;
6161import java .util .logging .Level ;
6262import static java .util .logging .Level .*;
63+ import static org .apache .commons .lang .StringUtils .defaultString ;
6364import static org .kohsuke .github .GitHub .MAPPER ;
6465
6566/**
@@ -76,7 +77,7 @@ class Requester {
7677 * Request method.
7778 */
7879 private String method = "POST" ;
79- private String contentType = "application/x-www-form-urlencoded" ;
80+ private String contentType = null ;
8081 private InputStream body ;
8182
8283 /**
@@ -392,18 +393,19 @@ public String getResponseHeader(String header) {
392393 private void buildRequest () throws IOException {
393394 if (isMethodWithBody ()) {
394395 uc .setDoOutput (true );
395- uc .setRequestProperty ("Content-type" , contentType );
396396
397397 if (body == null ) {
398+ uc .setRequestProperty ("Content-type" , defaultString (contentType ,"application/json" ));
398399 Map json = new HashMap ();
399400 for (Entry e : args ) {
400401 json .put (e .key , e .value );
401402 }
402403 MAPPER .writeValue (uc .getOutputStream (), json );
403404 } else {
405+ uc .setRequestProperty ("Content-type" , defaultString (contentType ,"application/x-www-form-urlencoded" ));
404406 try {
405407 byte [] bytes = new byte [32768 ];
406- int read = 0 ;
408+ int read ;
407409 while ((read = body .read (bytes )) != -1 ) {
408410 uc .getOutputStream ().write (bytes , 0 , read );
409411 }
0 commit comments