I realize the reason why it doesn't work is because,
HttpClient perform URL encoding explicitly on my payload. If I try to
try {
Socket socket = new Socket("www.xxx.com", 20000);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
final String body =
"[SORT]=0,1,0,10,5,0,KL,0&[FIELD]=33,38,51,58,68,88,78,98,99,101,56,57,69,70,71,72,89,90,91,92,59,60,61,62,79,80,81,82&[LIST]=1155.KL,1295.KL,7191.KL,0097.KL,2267.KL";
final int length = body.length();
final String s = "POST /%5bvUpJYKw4QvGRMBmhATUxRwv4JrU9aDnwNEuangVyy6OuHxi2YiY=%5dImage?
HTTP/1.1\r\nContent-Type: application/x-www-form-urlencoded\r\nCache-Control: no-cache\r\nPragma:
no-cache\r\nUser-Agent: Mozilla/4.0 (Windows XP 5.1) Java/1.6.0_06\r\nHost:
www.xxx.com:20000\r\nAccept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\nConnection:
keep-alive\r\nContent-Length: "+length+"\r\n\r\n" + body;
out.println(s);
BufferedReader in = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
while(true) {
String ss = in.readLine();
if (ss == null) break;
System.out.println(ss);
}
}
catch (Exception exp) {
}
It will work with payload :
- payload: HttpContentType = application/x-www-form-urlencoded
[SORT]: 0,1,0,10,5,0,KL,0
[FIELD]:
33,38,51,58,68,88,78,98,99,101,56,57,69,70,71,72,89,90,91,92,59,60,61,62,79,80,81,82
[LIST]: 1155.KL,1295.KL,7191.KL,0097.KL,2267.KL
May I know how can I disable URL encoding on my POST payload?