You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Trenton Lipscomb <tr...@gmail.com> on 2009/12/23 20:08:32 UTC

Setting Host header interferes with cookie manager

I'm attempting to the Host header in the header manager. I'm doing this
because the environment in which I'm testing does not have DNS... and even
if it did, I don't want to change my apache vhosts. I'd rather just send the
right Host.

When I specify the Host header and use an IP for the server, I don't see
cookies being sent in my requests. However, when I remove the Host header
and use a name for the server, everything works fine.

I guess I could work around by adding an /etc/hosts entry and using a name,
but it makes my testing much less portable.

*trenton
Sent from Wood Dale, IL, United States

Re: Setting Host header interferes with cookie manager

Posted by Trenton Lipscomb <tr...@gmail.com>.
>
> Two DNS names , even if they map to the same IP address arent the same
> for cookies.


I agree that's where I'm running into problems. The requirements for the
Host header [1] says it specifies the Internet host of the resource being
requested, as obtained from the original URI. In jmeter, I guess the
"original URL" is the server name/IP field + path, which would make sense. I
thought I could use the server name/IP field only for where to connect and
have the cookie manager look at the Host field for the cookies, but I guess
it doesn't work that way.

/etc/hosts is it.

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23

Re: Setting Host header interferes with cookie manager

Posted by Deepak Shetty <sh...@gmail.com>.
>More importantly, it's the exact same cookie domain
>and path if I use the server IP or name. It appears the cookie manager
won't
>*send* it if I'm using the IP.
and that behavior is correct. It is exactly how your browser would behave as
well. Two DNS names , even if they map to the same IP address arent the same
for cookies. Technically your application should not be setting cookies
based on the host header , it should be based on what the user has typed in
their browser.

Other than a beanshell script that would copy the cookie to the IP address ,
I dont see how you could get this to work without actually requesting the
DNS name from Jmeter (or an entry in the hosts file on the jmeter machine)

regards
deepak


On Wed, Dec 23, 2009 at 11:27 AM, Trenton Lipscomb <tr...@gmail.com>wrote:

> > I guesss the cookie is tied to the domain it receives (if you access a
> site
> > using Internet explorer with the IP address and get a cookie and then
> > access
> > it again but this time type the DNS , the browser will not send the
> > cookie).
> >
>
> Agreed, but that's slightly different that what I'm doing. That scenario
> would be analogous for using an IP in the Host header.
>
>
> > if you add a view results tree listener and check the Set-Cookie you
> > receive
> > does it have a domain?
> >
>
> It does. It's the exact same as the Host I'm requesting
>
> domain=.beta.mysite.com
>
> That would make sense, since it's Apache setting the cookie and it knows
> which vhost I requested. More importantly, it's the exact same cookie
> domain
> and path if I use the server IP or name. It appears the cookie manager
> won't
> *send* it if I'm using the IP. Perhaps it's using the server name as the
> key
> and not the Host header?
>
>
> > Also if you dont add a host header and just request using IP address what
> > happens?
> >
>
> Won't work because I have the site configured as a virtual host. It must
> get
> that Host header to know which host/docroot I want.
>

Re: Setting Host header interferes with cookie manager

Posted by Trenton Lipscomb <tr...@gmail.com>.
> I guesss the cookie is tied to the domain it receives (if you access a site
> using Internet explorer with the IP address and get a cookie and then
> access
> it again but this time type the DNS , the browser will not send the
> cookie).
>

Agreed, but that's slightly different that what I'm doing. That scenario
would be analogous for using an IP in the Host header.


> if you add a view results tree listener and check the Set-Cookie you
> receive
> does it have a domain?
>

It does. It's the exact same as the Host I'm requesting

domain=.beta.mysite.com

That would make sense, since it's Apache setting the cookie and it knows
which vhost I requested. More importantly, it's the exact same cookie domain
and path if I use the server IP or name. It appears the cookie manager won't
*send* it if I'm using the IP. Perhaps it's using the server name as the key
and not the Host header?


> Also if you dont add a host header and just request using IP address what
> happens?
>

Won't work because I have the site configured as a virtual host. It must get
that Host header to know which host/docroot I want.

Re: Setting Host header interferes with cookie manager

Posted by Deepak Shetty <sh...@gmail.com>.
I guesss the cookie is tied to the domain it receives (if you access a site
using Internet explorer with the IP address and get a cookie and then access
it again but this time type the DNS , the browser will not send the cookie).
if you add a view results tree listener and check the Set-Cookie you receive
does it have a domain?
Also if you dont add a host header and just request using IP address what
happens?

regards
deepak

On Wed, Dec 23, 2009 at 11:08 AM, Trenton Lipscomb <tr...@gmail.com>wrote:

> I'm attempting to the Host header in the header manager. I'm doing this
> because the environment in which I'm testing does not have DNS... and even
> if it did, I don't want to change my apache vhosts. I'd rather just send
> the
> right Host.
>
> When I specify the Host header and use an IP for the server, I don't see
> cookies being sent in my requests. However, when I remove the Host header
> and use a name for the server, everything works fine.
>
> I guess I could work around by adding an /etc/hosts entry and using a name,
> but it makes my testing much less portable.
>
> *trenton
> Sent from Wood Dale, IL, United States
>