You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Julius Davies <ju...@cucbc.com> on 2005/03/31 20:29:31 UTC
3.0-rc1 doesn't like my "host" header
Hi, Fellow HttpClient Users,
I'm getting different behaviour between 2.0.2 and 3.0 when I explicitly
set a "host" header.
Here's the code:
HttpClient client = new HttpClient();
GetMethod m = new GetMethod( "http://www.google.ca/" );
m.setRequestHeader( "host", "garbanzo" );
client.executeMethod( m );
How can I set the "host" header to "garbanzo" in 3.0?
commons-httpclient-3.0-rc1.jar
=========================================
>> "GET / HTTP/1.1[\r][\n]"
>> "User-Agent: Jakarta Commons-HttpClient/3.0-rc1[\r][\n]"
>> "Host: www.google.ca[\r][\n]"
commons-httpclient-2.0.2.jar
=========================================
>> "GET / HTTP/1.1[\r][\n]"
>> "host: garbanzo[\r][\n]"
>> "User-Agent: Jakarta Commons-HttpClient/2.0.2[\r][\n]"
yours,
Julius
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: 3.0-rc1 doesn't like my "host" header
Posted by Oleg Kalnichevski <ol...@apache.org>.
Julius
In HttpClient 3.0 use the following HTTP method parameter:
http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html#VIRTUAL_HOST
http://jakarta.apache.org/commons/httpclient/3.0/apidocs/org/apache/commons/httpclient/params/HttpMethodParams.html#setVirtualHost(java.lang.String)
For details on the new preference API see:
http://jakarta.apache.org/commons/httpclient/3.0/preference-api.html
Hope this helps
Oleg
On Thu, Mar 31, 2005 at 10:29:31AM -0800, Julius Davies wrote:
> Hi, Fellow HttpClient Users,
>
> I'm getting different behaviour between 2.0.2 and 3.0 when I explicitly
> set a "host" header.
>
> Here's the code:
>
> HttpClient client = new HttpClient();
> GetMethod m = new GetMethod( "http://www.google.ca/" );
> m.setRequestHeader( "host", "garbanzo" );
> client.executeMethod( m );
>
> How can I set the "host" header to "garbanzo" in 3.0?
>
>
> commons-httpclient-3.0-rc1.jar
> =========================================
> >> "GET / HTTP/1.1[\r][\n]"
> >> "User-Agent: Jakarta Commons-HttpClient/3.0-rc1[\r][\n]"
> >> "Host: www.google.ca[\r][\n]"
>
>
> commons-httpclient-2.0.2.jar
> =========================================
> >> "GET / HTTP/1.1[\r][\n]"
> >> "host: garbanzo[\r][\n]"
> >> "User-Agent: Jakarta Commons-HttpClient/2.0.2[\r][\n]"
>
>
> yours,
>
> Julius
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: 3.0-rc1 doesn't like my "host" header
Posted by Roland Weber <RO...@de.ibm.com>.
Hello Julies,
> How can I set the "host" header to "garbanzo" in 3.0?
by accessing a URL with "garbanzo" as the host name.
The behaviour in 2.0.2 is obviously wrong. HTTP/1.1
requests must contain a Host header specifying the
hostname of the URL that is accessed. Only the path
of the URL is in the first line of the request.
Try forcing HTTP/1.0 as the protocol, then HttpClient
does not need to set a Host header.
hope that helps,
Roland
Julius Davies <ju...@cucbc.com>
31.03.2005 20:29
Please respond to
"HttpClient User Discussion"
To
httpclient-user@jakarta.apache.org
cc
Subject
3.0-rc1 doesn't like my "host" header
Hi, Fellow HttpClient Users,
I'm getting different behaviour between 2.0.2 and 3.0 when I explicitly
set a "host" header.
Here's the code:
HttpClient client = new HttpClient();
GetMethod m = new GetMethod( "http://www.google.ca/" );
m.setRequestHeader( "host", "garbanzo" );
client.executeMethod( m );
How can I set the "host" header to "garbanzo" in 3.0?
commons-httpclient-3.0-rc1.jar
=========================================
>> "GET / HTTP/1.1[\r][\n]"
>> "User-Agent: Jakarta Commons-HttpClient/3.0-rc1[\r][\n]"
>> "Host: www.google.ca[\r][\n]"
commons-httpclient-2.0.2.jar
=========================================
>> "GET / HTTP/1.1[\r][\n]"
>> "host: garbanzo[\r][\n]"
>> "User-Agent: Jakarta Commons-HttpClient/2.0.2[\r][\n]"
yours,
Julius
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org