@@ -470,16 +470,26 @@ public void execute(String method, String url) {
470470 try (CloseableHttpClient httpClient = this .httpClientBuilder .build ()) {
471471
472472 if (method .equalsIgnoreCase ("GET" )) {
473- HttpGetWithBody httpget = new HttpGetWithBody (url .trim ());
474- httpget .setConfig (reqConfig );
475- Set <String > keys = getheadersToSend ().keySet ();
476- for (String header : keys ) {
477- httpget .addHeader (header , getheadersToSend ().get (header ));
473+ byte [] data = getData ();
474+ if (data .length > 0 ) {
475+ HttpGetWithBody httpGetWithBody = new HttpGetWithBody (url .trim ());
476+ httpGetWithBody .setConfig (reqConfig );
477+ Set <String > keys = getheadersToSend ().keySet ();
478+ for (String header : keys ) {
479+ httpGetWithBody .addHeader (header , getheadersToSend ().get (header ));
480+ }
481+ httpGetWithBody .setEntity (new ByteArrayEntity (data ));
482+ response = httpClient .execute (httpGetWithBody , httpClientContext );
483+ }
484+ else {
485+ HttpGet httpget = new HttpGet (url .trim ());
486+ httpget .setConfig (reqConfig );
487+ Set <String > keys = getheadersToSend ().keySet ();
488+ for (String header : keys ) {
489+ httpget .addHeader (header , getheadersToSend ().get (header ));
490+ }
491+ response = httpClient .execute (httpget , httpClientContext );
478492 }
479-
480- httpget .setEntity (new ByteArrayEntity (getData ()));
481-
482- response = httpClient .execute (httpget , httpClientContext );
483493
484494 } else if (method .equalsIgnoreCase ("POST" )) {
485495 HttpPost httpPost = new HttpPost (url .trim ());
0 commit comments