Skip to content

Commit

Permalink
Cherry pick branch 'genexuslabs:post-boundaries' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
iroqueta authored and Beta Bot committed Feb 20, 2025
1 parent 5aed751 commit 2a2d333
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/src/main/java/com/genexus/internet/GXHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,22 @@ protected String setPathUrl(String url) {
return url;
}

boolean firstMultiPart;
@SuppressWarnings("unchecked")
protected byte[] getData()
{
byte[] out = new byte[0];

firstMultiPart = false;
int variablesCount = getVariablesToSend().size();
int count = 1;
for (Object key: getVariablesToSend().keySet())
{
if (count == variablesCount)
firstMultiPart = true;
String value = getMultipartTemplate().getFormDataTemplate((String)key, (String)getVariablesToSend().get(key));
getContentToSend().add(0, value); //Variables al principio
count++;
}

for (int idx = 0; idx < getContentToSend().size(); idx++)
Expand Down Expand Up @@ -791,7 +798,10 @@ String getHeaderTemplate(String name, String fileName, String mimeType){
}
String getFormDataTemplate(String varName, String value){
String contentType = getContentTypeFromString(value);
return "--" + boundary + "\r\nContent-Disposition: form-data; name=\"" + varName + "\"\r\n" + ((contentType != null)? "Content-Type: " + contentType + "\r\n" : "") + "\r\n" + value + "\r\n";
String beginformDataTemplate = "\r\n--";
if (firstMultiPart)
beginformDataTemplate = "--";
return beginformDataTemplate + boundary + "\r\nContent-Disposition: form-data; name=\"" + varName + "\"\r\n" + ((contentType != null)? "Content-Type: " + contentType + "\r\n" : "") + "\r\n" + value;
}

private String getContentTypeFromString(String value){
Expand Down

0 comments on commit 2a2d333

Please sign in to comment.