JMeter POST文件使用Transfer-Encoding chunked

时间:2018-03-02 23:07:11

标签: jmeter

我正在使用JMeter来模拟将文件发送到我的服务器的设备。设备使用Transfer-Encoding chunked将数据发送到服务器。我试图将Transfer-Encoding设置为HTTP标头管理器的一部分,但是出现以下错误:

  
    

org.apache.http.client.ClientProtocolException         在org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:839)         在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)         at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:697)         在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)         在org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:490)         在org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:416)         在org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:250)         在java.lang.Thread.run(Thread.java:748)     引起:org.apache.http.ProtocolException:传输编码标头已存在         在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)         在org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:484)         在org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)`

  

如果我不包含Transfer-Encoding,我默认获得Content-Length,这意味着我没有使用chunked编码。

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)`

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

Header Manager docs

一样
  

Header Manager允许您添加或覆盖HTTP请求标头。

     

JMeter现在支持多个Header Manager。合并标头条目以形成采样器的列表。如果要合并的条目与现有标头名称匹配,则它将替换先前的条目

这意味着您需要将HTTP标头管理器添加为您的请求的,并使用最新的JMeter 4.0并且它将覆盖之前的任何值集。