Can't override Connection header

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't override Connection header

John.E.Gregg
I'm using JMeter 5.3.

I've added an http header manager with a Groovy script to vary the Http "Connection" header on each request.  Sometimes it's "Close," sometimes it's "Keep-alive."  This lets me simulate different http connection reuse scenarios.  However instead of setting or replacing the default Connection header, I actually get a second Connection header added.

I've tried using both the HttpClient 4 and Java implementations and still get duplicate Connection headers, sometimes with different values.

I've tried putting the header manager as a child of the http request and as a peer.

I've tried checking and unchecking the "Use KeepAlive" box on the request.

No matter what, I get two Connection headers.  One has the value I set and the other has the default value.

Is there a way to do this?  I haven't yet checked what the server will do

Thanks


Reply | Threaded
Open this post in threaded view
|

Re: Can't override Connection header

glinius@live.com
I don't think you can do this using HTTP Header Manager, the header is
controllable via "Use KeepAlive" box in HTTP Request sampler

If you need to parameterize the Connection header I can think of adding
JSR223 PreProcessor
<https://jmeter.apache.org/usermanual/component_reference.html#JSR223_PreProcessor>  
and using the following code:


> sampler.setUseKeepAlive(false) // for Connection: close

or


> sampler.setUseKeepAlive(true) // for Connection: keep-alive


Alternative option would be switching to  HTTP Raw Request sampler
<https://www.blazemeter.com/blog/the-jmeter-http-raw-request-sampler-when-and-how-to-use-it>  
which gives you full flexibility in building request headers and body



--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Can't override Connection header

John.E.Gregg
Thank you.  The preproccesor works.

> -----Original Message-----
> From: [hidden email] <[hidden email]>
> Sent: Wednesday, January 27, 2021 11:44 AM
> To: [hidden email]
> Subject: Re: Can't override Connection header
>
> I don't think you can do this using HTTP Header Manager, the header is
> controllable via "Use KeepAlive" box in HTTP Request sampler
>
> If you need to parameterize the Connection header I can think of adding
> JSR223 PreProcessor
> <https://jmeter.apache.org/usermanual/component_reference.html#JSR22
> 3_PreProcessor>
> and using the following code:
>
>
> > sampler.setUseKeepAlive(false) // for Connection: close
>
> or
>
>
> > sampler.setUseKeepAlive(true) // for Connection: keep-alive
>
>
> Alternative option would be switching to  HTTP Raw Request sampler
> <https://www.blazemeter.com/blog/the-jmeter-http-raw-request-sampler-
> when-and-how-to-use-it>
> which gives you full flexibility in building request headers and body
>
>
>
> --
> Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]