hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oz Levanon" <Oz.Leva...@mobixell.com>
Subject RE: Request parameters?
Date Thu, 02 Jul 2009 14:09:07 GMT
I'm not using httpclient version 4, so I couldn't compile your code, but
it seems to me your confusing two different types of parameters.
The parameter you want are the URL parameters. To send them simply add
your data to the URL you create (taking care to put "?" before the first
parameter and "&" before subsequent parameters). For example:

HttpUriRequest httpGet = new
HttpGet("http://www.someserver.com/servlet?parm1=value1&parm2=value2&par
m3=value3");

I believe the parameters you set in the code below (I could be wrong,
since I don't have access to the code) are HTTP Connection Parameters,
which are parameters that are passed on the HTTP connection (e.g.
"host", "user-agent", etc.) and can be seen by sniffing the traffic
(using WireShark, or tcpdump, for example).

Please also note that parameters in the request must be escaped, i.e.
you must replaced any special characters (e.g. %) with an escaping
sequence, so that the parser won't confuse them with the special
character's function (see
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm) 

HTH,
Oz

-----Original Message-----
From: Kevin Roll [mailto:kroll@appropel.com] 
Sent: Thursday, July 02, 2009 4:40 PM
To: httpclient-users@hc.apache.org
Subject: Request parameters?

I'm trying to use httpclient-4.0-beta2 to achieve what seems like a  
simple thing. I want to make a request to a certain URL with a set of  
parameters. My code looks like this:

HttpParams params = new BasicHttpParams();
params.setParameter("someparam", "somevalue");
		
HttpClient httpClient = new DefaultHttpClient();
HttpUriRequest httpGet = new HttpGet("http://www.someserver.com/ 
servlet");
httpGet.setParams(params);

HttpResponse response = httpClient.execute(httpGet);


So, I would expect that a URL would be generated that looks like

http://www.someserver/com/servlet?someparam=somevalue

No matter what I do it seems that my parameters are ignored, causing  
an error response from the server. Surprisingly none of the examples  
cover this simple case. Am I doing something obviously wrong here?  
Thanks!


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


---------------------------------------------------------------------
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