Skip to content

Commit ce111fd

Browse files
author
Igor Polevoy
committed
#580 Equal sign is not legal character in boundary.
1 parent 8123292 commit ce111fd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

javalite-common/src/main/java/org/javalite/http/Multipart.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
package org.javalite.http;
22

3+
import org.javalite.common.Inflector;
4+
35
import java.io.*;
46
import java.net.URLConnection;
57
import java.util.ArrayList;
68
import java.util.List;
9+
import java.util.UUID;
710

811
/**
912
* Sets up a Multipart request to send multiple text fields as well as upload files.
1013
*
1114
* @author Igor Polevoy on 5/1/16.
1215
*/
1316
public class Multipart extends Request<Multipart> {
17+
18+
private static final String DASH = "------";
1419
private static final String LINE_FEED = "\r\n";
1520

1621
private PrintWriter writer;
1722
private String boundary;
1823
private OutputStream outputStream;
1924
private List<FormField> formFields = new ArrayList<>();
2025

26+
27+
2128
/**
22-
* Contructor to make multipart requests
29+
* Constructor to make multipart requests
30+
*
2331
* @param url URL to send request to
2432
* @param connectTimeout connection timeout
2533
* @param readTimeout read timeout
@@ -32,7 +40,7 @@ public Multipart(String url, int connectTimeout, int readTimeout) {
3240
protected Multipart doConnect() {
3341

3442
try {
35-
boundary = "===" + System.currentTimeMillis() + "===";
43+
boundary = "JavaLite-HTTP-"+ UUID.randomUUID() ;
3644
connection.setUseCaches(false);
3745
connection.setDoOutput(true); // indicates POST method
3846
connection.setDoInput(true);
@@ -159,9 +167,12 @@ public Multipart file(String fieldName, String filePath ){
159167
}
160168

161169
public static void main(String[] args){
170+
171+
//use kitchensink
162172
Multipart mp = Http.multipart("http://localhost:8080/upload/save")
163173
.field("name1", "val1")
164174
.file("file1", "/home/igor/tmp/test.txt");
165-
System.out.println(mp.text());
175+
176+
System.out.println(mp.headers());
166177
}
167178
}

0 commit comments

Comments
 (0)