4

I've set almost all my data :

String capcha = editText.getText().toString();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("myurl.asp");

// Add your data                    
String str = "param1=x&param2=y";
StringEntity strEntity = new StringEntity(str);
httppost.setEntity(strEntity);

httppost.setHeader("Set-Cookie", sessionCookie);
httppost.setHeader("Accept", "text/html");
httppost.setHeader("Content-Type", "application/x-www-form-urlencoded");
// httppost.setHeader("Content-Length", ); HOW TO GET CONTENT LENGTH ?

// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);

Thanks for your help.

Rob
  • 15,732
  • 22
  • 69
  • 107
  • @Waqas the question of the link refers to `HttpUrlConnection` which I'm not using. How can I do so? – Rob Nov 17 '13 at 23:56

1 Answers1

5

Perhaps this may help to solve your problem:

httppost.setHeader("Content-Length", String.valueOf(strEntity.getContentLength()));
waqaslam
  • 67,549
  • 16
  • 165
  • 178