Skip to content

Commit 2a2d333

Browse files
iroquetaBeta Bot
authored andcommitted
Cherry pick branch 'genexuslabs:post-boundaries' into beta
1 parent 5aed751 commit 2a2d333

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

common/src/main/java/com/genexus/internet/GXHttpClient.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,15 +567,22 @@ protected String setPathUrl(String url) {
567567
return url;
568568
}
569569

570+
boolean firstMultiPart;
570571
@SuppressWarnings("unchecked")
571572
protected byte[] getData()
572573
{
573574
byte[] out = new byte[0];
574575

576+
firstMultiPart = false;
577+
int variablesCount = getVariablesToSend().size();
578+
int count = 1;
575579
for (Object key: getVariablesToSend().keySet())
576580
{
581+
if (count == variablesCount)
582+
firstMultiPart = true;
577583
String value = getMultipartTemplate().getFormDataTemplate((String)key, (String)getVariablesToSend().get(key));
578584
getContentToSend().add(0, value); //Variables al principio
585+
count++;
579586
}
580587

581588
for (int idx = 0; idx < getContentToSend().size(); idx++)
@@ -791,7 +798,10 @@ String getHeaderTemplate(String name, String fileName, String mimeType){
791798
}
792799
String getFormDataTemplate(String varName, String value){
793800
String contentType = getContentTypeFromString(value);
794-
return "--" + boundary + "\r\nContent-Disposition: form-data; name=\"" + varName + "\"\r\n" + ((contentType != null)? "Content-Type: " + contentType + "\r\n" : "") + "\r\n" + value + "\r\n";
801+
String beginformDataTemplate = "\r\n--";
802+
if (firstMultiPart)
803+
beginformDataTemplate = "--";
804+
return beginformDataTemplate + boundary + "\r\nContent-Disposition: form-data; name=\"" + varName + "\"\r\n" + ((contentType != null)? "Content-Type: " + contentType + "\r\n" : "") + "\r\n" + value;
795805
}
796806

797807
private String getContentTypeFromString(String value){

0 commit comments

Comments
 (0)