hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Fran├žois Rey <charlesfr....@gmail.com>
Subject Re: HttpClient 4.0 httppost with parameters
Date Tue, 27 Oct 2009 14:00:13 GMT
I've tried your example and I do see the parameters in the analyzer (I  
use WireShark). Keep in mind that the actual http request and the  
content can be split across multiple frames, so be sure to examine the  
reassembled data, not below the TCP level.

The content-length of 23 corresponds effectively to your 6 key+values  
with '=' and 5 '&' in between.

On 27 oct. 09, at 13:17, 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.
>
> Thanks
>
> Tobias

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message