You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by apc <ap...@apc.kg> on 2011/04/11 09:55:37 UTC

How to override Host header

How can I override Host header in HTTP request?

I tried adding HTTP Header Manager and set Host header in it, but I see no
changes in my HTTP requests.

Adding to "hosts" file is not applicable since I have no root privileges at
test generator.

Any ideas?

Best regards,
Andrey

--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4295391.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by sebb <se...@gmail.com>.
On 11 April 2011 18:50, Deepak Shetty <sh...@gmail.com> wrote:
>>I don't know whether the Http implementations allow the host to be
>>specified
> HTTP Client does allow you to override the host header and specify a virtual
> host (e.g. when implementing a reverse proxy this is useful)

Thanks.

In which case, the OP may wish to use Bugzilla to create an
enhancement request to allow the Header Manager to provide the Host
name.
This might also affect Proxy recording.

> regards
> deepak
>
> On Mon, Apr 11, 2011 at 3:16 AM, sebb <se...@gmail.com> wrote:
>
>> On 11 April 2011 08:55, apc <ap...@apc.kg> wrote:
>> > How can I override Host header in HTTP request?
>>
>> The Host header is generated by the HTTP stack from the URL, and
>> cannot currently be overridden.
>>
>> > I tried adding HTTP Header Manager and set Host header in it, but I see
>> no
>> > changes in my HTTP requests.
>>
>> See above.
>>
>> > Adding to "hosts" file is not applicable since I have no root privileges
>> at
>> > test generator.
>> >
>> > Any ideas?
>>
>> If the target host is a virtual host, at some point the virtual host
>> names will need to be defined in DNS, otherwise it will not be
>> accessible by browsers. So maybe you can bring that stage forward.
>>
>> I don't know whether the Http implementations allow the host to be
>> specified; your only other option at present is to change the JMeter
>> code locally to remove the host restriction.
>>
>> > Best regards,
>> > Andrey
>> >
>> > --
>> > View this message in context:
>> http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4295391.html
>> > Sent from the JMeter - User mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by haridsv <ha...@gmail.com>.
On Sun, May 22, 2011 at 6:57 AM, sebb-2-2 [via JMeter]
<ml...@n5.nabble.com> wrote:
>
> >> I went ahead and opened this enhancement request:
> >> https://issues.apache.org/bugzilla/show_bug.cgi?id=51238
> >
> > Thanks.
> >
> > As noted there, you can edit the system.properties file to define the property.
> >
> > Perhaps that should be done by default for the next release of JMeter?
> >>
>
> On further reflection, JMeter should be able to set whatever headers
> it wants, so the next release of JMeter will include this by default.

Thank you, appreciate fixing it.

-- 
Hari


--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4418198.html
Sent from the JMeter - User mailing list archive at Nabble.com.

Re: How to override Host header

Posted by sebb <se...@gmail.com>.
On 21 May 2011 10:12, sebb <se...@gmail.com> wrote:
> On 21 May 2011 02:06, haridsv <ha...@gmail.com> wrote:
>> I needed to override Host header and debugged a little to find that this
>> header is being considered as one of the "restricted" headers and so is
>> being silently dropped. The workaround is to set
>> "sun.net.http.allowRestrictedHeaders" to "true". I was able to verify that
>> this works by passing in -Dsun.net.http.allowRestrictedHeaders=true
>> argument on the command-line. When I tried to set the same property in the
>> context of a User Defined Variable using __setProperty() function, I could
>> see that the property value has changed, but the Host header was still
>> dropped, suggesting that the property value needs to be changed sooner than
>> that. I am not sure if there is another context that can make it possible to
>> programmatically change this value.
>>
>> I went ahead and opened this enhancement request:
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=51238
>
> Thanks.
>
> As noted there, you can edit the system.properties file to define the property.
>
> Perhaps that should be done by default for the next release of JMeter?

On further reflection, JMeter should be able to set whatever headers
it wants, so the next release of JMeter will include this by default.

> Or should it be up to users to define the value?
>
> In any case, it would make sense to at least add a comment in the file
> about the setting.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by sebb <se...@gmail.com>.
On 21 May 2011 02:06, haridsv <ha...@gmail.com> wrote:
> I needed to override Host header and debugged a little to find that this
> header is being considered as one of the "restricted" headers and so is
> being silently dropped. The workaround is to set
> "sun.net.http.allowRestrictedHeaders" to "true". I was able to verify that
> this works by passing in -Dsun.net.http.allowRestrictedHeaders=true
> argument on the command-line. When I tried to set the same property in the
> context of a User Defined Variable using __setProperty() function, I could
> see that the property value has changed, but the Host header was still
> dropped, suggesting that the property value needs to be changed sooner than
> that. I am not sure if there is another context that can make it possible to
> programmatically change this value.
>
> I went ahead and opened this enhancement request:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=51238

Thanks.

As noted there, you can edit the system.properties file to define the property.

Perhaps that should be done by default for the next release of JMeter?

Or should it be up to users to define the value?

In any case, it would make sense to at least add a comment in the file
about the setting.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by haridsv <ha...@gmail.com>.
I needed to override Host header and debugged a little to find that this
header is being considered as one of the "restricted" headers and so is
being silently dropped. The workaround is to set
"sun.net.http.allowRestrictedHeaders" to "true". I was able to verify that
this works by passing in -Dsun.net.http.allowRestrictedHeaders=true 
argument on the command-line. When I tried to set the same property in the
context of a User Defined Variable using __setProperty() function, I could
see that the property value has changed, but the Host header was still
dropped, suggesting that the property value needs to be changed sooner than
that. I am not sure if there is another context that can make it possible to
programmatically change this value.

I went ahead and opened this enhancement request:
https://issues.apache.org/bugzilla/show_bug.cgi?id=51238

--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4413871.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by sebb <se...@gmail.com>.
On 4 May 2011 06:31, dmitry.hohlov <dm...@mail.ru> wrote:
>
> Deepak Shetty wrote:
>>
>> HTTP Client does allow you to override the host header and specify a
>> virtual
>> host (e.g. when implementing a reverse proxy this is useful)
>>
>
> How this can be done?

[As already stated:]

Not currently possible. You would need to change the JMeter code.

Feel free to raise a Bugzilla enhancement request.

> I put a "HTTP Header Manager" (with a "Host" header
> specified in it) into a "HTTP Request HTTPClient" sampler (where "Server
> Name" is provided as an IP address and "Port Number" is also specified as it
> is non-standart). After that (as tcpdump on the target server says) the
> "Host" header in the request from JMeter still contains "IP:port" but not
> the domain name provided in the "HTTP Header Manager".
>
> I use JMeter 2.4 r961953 with JRE 1.6.0_24 on Windows 7 Starter SP1.
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4369094.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by "dmitry.hohlov" <dm...@mail.ru>.
Deepak Shetty wrote:
> 
> HTTP Client does allow you to override the host header and specify a
> virtual
> host (e.g. when implementing a reverse proxy this is useful)
> 

How this can be done? I put a "HTTP Header Manager" (with a "Host" header
specified in it) into a "HTTP Request HTTPClient" sampler (where "Server
Name" is provided as an IP address and "Port Number" is also specified as it
is non-standart). After that (as tcpdump on the target server says) the
"Host" header in the request from JMeter still contains "IP:port" but not
the domain name provided in the "HTTP Header Manager".

I use JMeter 2.4 r961953 with JRE 1.6.0_24 on Windows 7 Starter SP1.

--
View this message in context: http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4369094.html
Sent from the JMeter - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Re: How to override Host header

Posted by Deepak Shetty <sh...@gmail.com>.
>I don't know whether the Http implementations allow the host to be
>specified
HTTP Client does allow you to override the host header and specify a virtual
host (e.g. when implementing a reverse proxy this is useful)

regards
deepak

On Mon, Apr 11, 2011 at 3:16 AM, sebb <se...@gmail.com> wrote:

> On 11 April 2011 08:55, apc <ap...@apc.kg> wrote:
> > How can I override Host header in HTTP request?
>
> The Host header is generated by the HTTP stack from the URL, and
> cannot currently be overridden.
>
> > I tried adding HTTP Header Manager and set Host header in it, but I see
> no
> > changes in my HTTP requests.
>
> See above.
>
> > Adding to "hosts" file is not applicable since I have no root privileges
> at
> > test generator.
> >
> > Any ideas?
>
> If the target host is a virtual host, at some point the virtual host
> names will need to be defined in DNS, otherwise it will not be
> accessible by browsers. So maybe you can bring that stage forward.
>
> I don't know whether the Http implementations allow the host to be
> specified; your only other option at present is to change the JMeter
> code locally to remove the host restriction.
>
> > Best regards,
> > Andrey
> >
> > --
> > View this message in context:
> http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4295391.html
> > Sent from the JMeter - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Re: How to override Host header

Posted by sebb <se...@gmail.com>.
On 11 April 2011 08:55, apc <ap...@apc.kg> wrote:
> How can I override Host header in HTTP request?

The Host header is generated by the HTTP stack from the URL, and
cannot currently be overridden.

> I tried adding HTTP Header Manager and set Host header in it, but I see no
> changes in my HTTP requests.

See above.

> Adding to "hosts" file is not applicable since I have no root privileges at
> test generator.
>
> Any ideas?

If the target host is a virtual host, at some point the virtual host
names will need to be defined in DNS, otherwise it will not be
accessible by browsers. So maybe you can bring that stage forward.

I don't know whether the Http implementations allow the host to be
specified; your only other option at present is to change the JMeter
code locally to remove the host restriction.

> Best regards,
> Andrey
>
> --
> View this message in context: http://jmeter.512774.n5.nabble.com/How-to-override-Host-header-tp4295391p4295391.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org