@@ -486,16 +486,26 @@ public void execute(String method, String url) {
486486
487487 try (CloseableHttpClient httpClient = this .httpClientBuilder .build ()) {
488488 if (method .equalsIgnoreCase ("GET" )) {
489- HttpGetWithBody httpget = new HttpGetWithBody (url .trim ());
490- httpget .setConfig (reqConfig );
491- Set <String > keys = getheadersToSend ().keySet ();
492- for (String header : keys ) {
493- httpget .addHeader (header , getheadersToSend ().get (header ));
489+ byte [] data = getData ();
490+ if (data .length > 0 ) {
491+ HttpGetWithBody httpGetWithBody = new HttpGetWithBody (url .trim ());
492+ httpGetWithBody .setConfig (reqConfig );
493+ Set <String > keys = getheadersToSend ().keySet ();
494+ for (String header : keys ) {
495+ httpGetWithBody .addHeader (header , getheadersToSend ().get (header ));
496+ }
497+ httpGetWithBody .setEntity (new ByteArrayEntity (data ));
498+ response = httpClient .execute (httpGetWithBody , httpClientContext );
499+ }
500+ else {
501+ HttpGet httpget = new HttpGet (url .trim ());
502+ httpget .setConfig (reqConfig );
503+ Set <String > keys = getheadersToSend ().keySet ();
504+ for (String header : keys ) {
505+ httpget .addHeader (header , getheadersToSend ().get (header ));
506+ }
507+ response = httpClient .execute (httpget , httpClientContext );
494508 }
495-
496- httpget .setEntity (new ByteArrayEntity (getData ()));
497-
498- response = httpClient .execute (httpget , httpClientContext );
499509
500510 } else if (method .equalsIgnoreCase ("POST" )) {
501511 HttpPost httpPost = new HttpPost (url .trim ());
0 commit comments