Skip to content

Commit

Permalink
Cherry pick branch 'genexuslabs:HttpClientGetContentLength' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
iroqueta authored and Beta Bot committed Dec 10, 2024
1 parent 5342e52 commit 8c544a6
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions java/src/main/java/com/genexus/internet/HttpClientJavaLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,26 @@ public void execute(String method, String url) {
try (CloseableHttpClient httpClient = this.httpClientBuilder.build()) {

if (method.equalsIgnoreCase("GET")) {
HttpGetWithBody httpget = new HttpGetWithBody(url.trim());
httpget.setConfig(reqConfig);
Set<String> keys = getheadersToSend().keySet();
for (String header : keys) {
httpget.addHeader(header, getheadersToSend().get(header));
byte[] data = getData();
if (data.length > 0) {
HttpGetWithBody httpGetWithBody = new HttpGetWithBody(url.trim());
httpGetWithBody.setConfig(reqConfig);
Set<String> keys = getheadersToSend().keySet();
for (String header : keys) {
httpGetWithBody.addHeader(header, getheadersToSend().get(header));
}
httpGetWithBody.setEntity(new ByteArrayEntity(data));
response = httpClient.execute(httpGetWithBody, httpClientContext);
}
else {
HttpGet httpget = new HttpGet(url.trim());
httpget.setConfig(reqConfig);
Set<String> keys = getheadersToSend().keySet();
for (String header : keys) {
httpget.addHeader(header, getheadersToSend().get(header));
}
response = httpClient.execute(httpget, httpClientContext);
}

httpget.setEntity(new ByteArrayEntity(getData()));

response = httpClient.execute(httpget, httpClientContext);

} else if (method.equalsIgnoreCase("POST")) {
HttpPost httpPost = new HttpPost(url.trim());
Expand Down

0 comments on commit 8c544a6

Please sign in to comment.