Skip to content

Commit 8c544a6

Browse files
iroquetaBeta Bot
authored andcommitted
Cherry pick branch 'genexuslabs:HttpClientGetContentLength' into beta
1 parent 5342e52 commit 8c544a6

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

java/src/main/java/com/genexus/internet/HttpClientJavaLib.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)