0
votes

I am using JMeter to simulate a device sending a file to my server. The device uses a Transfer-Encoding chunked to send data to the server. I have attempted to set the Transfer-Encoding as part of the HTTP Header Manager but get the following error:

org.apache.http.client.ClientProtocolException at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:839) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:697) at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:455) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189) at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178) at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490) at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416) at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250) at java.lang.Thread.run(Thread.java:748) Caused by: org.apache.http.ProtocolException: Transfer-encoding header already present at org.apache.http.protocol.RequestContent.process(RequestContent.java:94) at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:133) at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:167) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:484) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)`

If I don't include the Transfer-Encoding I get a Content-Length by default which means I am not using chunked encoding.

Request Headers:
Connection: keep-alive
Content-Type: application/octet-stream
Accept-Language: en-US
Accept: application/json
Content-Length: 9353
User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_152)`

Any assistance would be greatly appreciated.

1

1 Answers

0
votes

As in Header Manager docs

The Header Manager lets you add or override HTTP request headers.

JMeter now supports multiple Header Managers. The header entries are merged to form the list for the sampler. If an entry to be merged matches an existing header name, it replaces the previous entry

Meaning you need to add HTTP Header Manager as the child of your request, and use latest JMeter 4.0 and it'll override any previous value set.