Skip to content

Commit fddd08b

Browse files
committed
select encoding to post data
1 parent 5f32946 commit fddd08b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/http/requests/PostRequest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ public class PostRequest
2626
HashMap<String,File> nameFilePairs;
2727

2828
String content;
29+
String encoding;
2930
HttpResponse response;
3031

31-
public PostRequest(String url)
32+
public PostRequest(String url)
33+
{
34+
this(url, "ISO-8859-1");
35+
}
36+
37+
public PostRequest(String url, String encoding)
3238
{
3339
this.url = url;
40+
this.encoding = encoding;
3441
nameValuePairs = new ArrayList<BasicNameValuePair>();
3542
nameFilePairs = new HashMap<String,File>();
3643
}
@@ -57,7 +64,7 @@ public void send()
5764
HttpPost httpPost = new HttpPost(url);
5865

5966
if (nameFilePairs.isEmpty()) {
60-
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
67+
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, encoding));
6168
} else {
6269
MultipartEntity mentity = new MultipartEntity();
6370
Iterator<Entry<String,File>> it = nameFilePairs.entrySet().iterator();

0 commit comments

Comments
 (0)