android - HttpClient VS Jsoup : Http package header look the same but not the response is difference? -


as following image capture wireshark, the left side package create jsoup code.

connection.response response = jsoup.connect("http://pantip.com/login/authentication")             .header("content-type", "application/x-www-form-urlencoded")             .timeout(9000)             .method(connection.method.post)             .data("member[email]", username, "member[crypted_password]", password, "action", "login", "redirect", "")             .followredirects(false)             .execute(); 

right hand side package create httpclient following code.

 list<namevaluepair> nvps = new arraylist<namevaluepair>();     nvps.add(new basicnamevaluepair("member[email]", username));     nvps.add(new basicnamevaluepair("member[crypted_password]", password));     nvps.add(new basicnamevaluepair("action", "login"));     nvps.add(new basicnamevaluepair("redirect", ""));      httppost postlogin = new httppost("http://pantip.com/login/authentication");      postlogin.setentity(new stringentity("member[email]="+username+"&member[crypted_password]="+password+"&action=login&redirect="));     postlogin.addheader("content-type", "application/x-www-form-urlencoded");     postlogin.addheader("accept-encoding", "gzip");     postlogin.addheader("user-agent", "dalvik/1.4.0 (linux; u; android 2.3.7; full android on x86 emulator build/gingerbread)"); 

i try set every header same value include user agent. package login website.

my problem is left hand side package create jsoup working when use httpclient, server response login incorrect request package same, why?

on android project, have use httpclient. constrain.

package compare

you might have set content type in stringentity object. why making basicnamevaluepairs using string?


Comments