Tobias Frei wrote:
Hello together, i am a new subsciber to this mailing list and i hope that anyone can help.I am trying to simulate a login to a webpage via a httppost-request. When i send the post, i cannot see the pair parameter/value in the post-data section of my http sniffer. When i try to send the information via a webbrowser, i can see the right data in the sniffer. Strangely in the header of the request, i see a content-length of 23. Where are the parameters, what is wrong with my request? Here is the relevant part of my code: public void sendLoginInformation(){ HttpPost httppost=new HttpPost(ggserverurl+phpexec); HttpResponse response; HttpEntity entity; BufferedReader bufferedreader; List <NameValuePair> parameters = new ArrayList <NameValuePair>(); parameters.add(new BasicNameValuePair("a", "a")); parameters.add(new BasicNameValuePair("b", "b")); parameters.add(new BasicNameValuePair("c", "c")); parameters.add(new BasicNameValuePair("d", "e")); parameters.add(new BasicNameValuePair("e", "f")); parameters.add(new BasicNameValuePair("f", "g")); try { UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8); httppost.setEntity(sendentity); response=httpclient.execute(httppost); entity=response.getEntity(); /**if (entity!=null){ bufferedreader=new BufferedReader(new InputStreamReader (new BufferedInputStream(entity.getContent()))); int i; for(i=0;i<1000;i++)System.out.println(bufferedreader.readLine()); }**/ } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Help would be appreciated.
You can use wire logging to see what gets sent across the wire http://hc.apache.org/httpcomponents-client/logging.html Oleg
Thanks Tobias
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
