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 "Mclean, Brendan" <bm...@networksolutions.com> on 2008/04/15 17:07:00 UTC
Problem with order of request host header
Hi,
I'm looking for a workaround to httpclient (3.1) where every request
sent across the wire has the host header as the last and final header
sent.
It seems no matter what order I call
add/setRequestHeader("host","blahh"), the host header is always sent
last.
I realize that according to the HTTP spec this shouldn't matter, but
it's causing a problem with a very small minorty of webservers.
Example request logs sent with telent:
Generated by httpclient:
GET /index.asp?PageAction=CARTDETAILS HTTP/1.1
accept:
image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/vnd.ms-exce
l,application/vnd.ms-powerpoint,application/msword,application/x-shockwa
ve-flash,*/*
referer: http://www.dieselpro.com/index.asp
accept-language: en-us
ua-cpu: x86
accept-encoding: gzip,deflate
user-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
1.1.4322; InfoPath.1; .NET CLR 2.0.50727)
connection: Keep-Alive
cache-control: no-cache
Cookie: ASPSESSIONIDCQRDRRQD=GCOIKOIBDLGCAIPDGMMNDHOG; __utmc=92942360;
ASPSESSIONIDAQQDRQQC=GMOHGHDCIDGCELGDOJDJKMCK; CustID=44941;
__utma=92942360.414594330.1208266072.1208266072.1208266072.1;
__utmb=92942360;
__utmz=92942360.1208266072.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(n
one)
Host: www.dieselpro.com
HTTP/1.1 400 Bad Request
Date: Tue, 15 Apr 2008 14:10:46 GMT
Server: WebServer 3-9
Content-Length: 4009
Connection: close
Content-Type: text/html
--------------------------------
Now manually put the host header anywhere but last and send with telnet:
GET /index.asp?PageAction=CARTDETAILS HTTP/1.1
accept:
image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/vnd.ms-exce
l,application/vnd.ms-powerpoint,application/msword,application/x-shockwa
ve-flash,*/*
referer: http://www.dieselpro.com/index.asp
accept-language: en-us
ua-cpu: x86
accept-encoding: gzip,deflate
user-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
1.1.4322; InfoPath.1; .NET CLR 2.0.50727)
connection: Keep-Alive
cache-control: no-cache
Host: www.dieselpro.com
Cookie: ASPSESSIONIDCQRDRRQD=GCOIKOIBDLGCAIPDGMMNDHOG; __utmc=92942360;
ASPSESSIONIDAQQDRQQC=GMOHGHDCIDGCELGDOJDJKMCK; CustID=44941;
__utma=92942360.414594330.1208266072.1208266072.1208266072.1;
__utmb=92942360;
__utmz=92942360.1208266072.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(n
one)
HTTP/1.1 200 OK
Date: Tue, 15 Apr 2008 14:12:44 GMT
Server: WebServer 3-9
Set-Cookie: CustID=44962; expires=Wed, 15-Apr-2009 14:12:44 GMT; path=/
Set-Cookie: ASPSESSIONIDAQQDRQQC=KLBIGHDCLKFGFEKECKFEBMLB; path=/
cache-control: private
Cache-control: private
Connection: close
Content-Type: text/html
X-Powered-By:WebServer
X-Powered-By: ASP.NET
pragma: no-cache
Re: Problem with order of request host header
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2008-04-15 at 11:07 -0400, Mclean, Brendan wrote:
> Hi,
>
> I'm looking for a workaround to httpclient (3.1) where every request
> sent across the wire has the host header as the last and final header
> sent.
> It seems no matter what order I call
> add/setRequestHeader("host","blahh"), the host header is always sent
> last.
>
> I realize that according to the HTTP spec this shouldn't matter, but
> it's causing a problem with a very small minorty of webservers.
>
The only option is to override HttpMethodBase#addHostRequestHeader
http://hc.apache.org/httpclient-3.x/xref/org/apache/commons/httpclient/HttpMethodBase.html#1326
Oleg
> Example request logs sent with telent:
>
> Generated by httpclient:
>
> GET /index.asp?PageAction=CARTDETAILS HTTP/1.1
> accept:
> image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/vnd.ms-exce
> l,application/vnd.ms-powerpoint,application/msword,application/x-shockwa
> ve-flash,*/*
> referer: http://www.dieselpro.com/index.asp
> accept-language: en-us
> ua-cpu: x86
> accept-encoding: gzip,deflate
> user-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
> 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)
> connection: Keep-Alive
> cache-control: no-cache
> Cookie: ASPSESSIONIDCQRDRRQD=GCOIKOIBDLGCAIPDGMMNDHOG; __utmc=92942360;
> ASPSESSIONIDAQQDRQQC=GMOHGHDCIDGCELGDOJDJKMCK; CustID=44941;
> __utma=92942360.414594330.1208266072.1208266072.1208266072.1;
> __utmb=92942360;
> __utmz=92942360.1208266072.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(n
> one)
> Host: www.dieselpro.com
>
>
> HTTP/1.1 400 Bad Request
> Date: Tue, 15 Apr 2008 14:10:46 GMT
> Server: WebServer 3-9
> Content-Length: 4009
> Connection: close
> Content-Type: text/html
>
> --------------------------------
>
> Now manually put the host header anywhere but last and send with telnet:
>
> GET /index.asp?PageAction=CARTDETAILS HTTP/1.1
> accept:
> image/gif,image/x-xbitmap,image/jpeg,image/pjpeg,application/vnd.ms-exce
> l,application/vnd.ms-powerpoint,application/msword,application/x-shockwa
> ve-flash,*/*
> referer: http://www.dieselpro.com/index.asp
> accept-language: en-us
> ua-cpu: x86
> accept-encoding: gzip,deflate
> user-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
> 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)
> connection: Keep-Alive
> cache-control: no-cache
> Host: www.dieselpro.com
> Cookie: ASPSESSIONIDCQRDRRQD=GCOIKOIBDLGCAIPDGMMNDHOG; __utmc=92942360;
> ASPSESSIONIDAQQDRQQC=GMOHGHDCIDGCELGDOJDJKMCK; CustID=44941;
> __utma=92942360.414594330.1208266072.1208266072.1208266072.1;
> __utmb=92942360;
> __utmz=92942360.1208266072.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(n
> one)
>
>
> HTTP/1.1 200 OK
> Date: Tue, 15 Apr 2008 14:12:44 GMT
> Server: WebServer 3-9
> Set-Cookie: CustID=44962; expires=Wed, 15-Apr-2009 14:12:44 GMT; path=/
> Set-Cookie: ASPSESSIONIDAQQDRQQC=KLBIGHDCLKFGFEKECKFEBMLB; path=/
> cache-control: private
> Cache-control: private
> Connection: close
> Content-Type: text/html
> X-Powered-By:WebServer
> X-Powered-By: ASP.NET
> pragma: no-cache
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org