【问题标题】:Transfer-encoding header already present error in JMeter HTTP RequestJMeter HTTP 请求中的传输编码标头已存在错误
【发布时间】:2014-08-28 15:13:08
【问题描述】:

我在 jmeter 的响应数据选项卡中不断收到以下错误:

org.apache.http.client.ClientProtocolException
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:909)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:481)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:298)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1105)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1094)
    at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.http.ProtocolException: Transfer-encoding header already present
    at org.apache.http.protocol.RequestContent.process(RequestContent.java:93)
    at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:109)
    at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:176)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:518)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
    ... 9 more

我的测试脚本是通过 JMeter 代理创建的。该测试通过 POST 将多部分数据(jpg 图像)发送到 REST API 资源。由 JMeter 中的 Recording Controller 自动创建的 HTTP Header Manager 具有以下内容:

Transfer-Encoding : chunked
Accept : application/json
Accept-Encoding : gzip, deflate

知道为什么响应会出错吗?

请求:

POST http://localhost:8080/email/v2/client/user/name/loadtest1@test.net/

POST data:
--oYtJU-XXTgMSkyaIrRBYNXw8AfMA2nMQSzJ20bJr--


Cookie Data:
JSESSIONID=b3bb843e-dafd-4cc5-8b0b-045c490736f8

Request Headers:
Connection: keep-alive
Transfer-Encoding: chunked
Accept: application/json
Accept-Encoding: gzip, deflate

【问题讨论】:

    标签: java apache http http-headers jmeter


    【解决方案1】:

    尝试从 HTTP 标头管理器中删除 Transfer-Encoding 标头。

    您能在您的问题中向您展示 Http 请求吗?以及里面的Header Manager?

    【讨论】:

    • 我尝试删除 Transfer-Encoding 标头并收到相同的错误。在我提出请求的 OP 中,Header Manager 已经在 OP 中。
    • 那么成功了吗?你能提供更多我感兴趣的细节吗,谢谢
    • 我需要删除 Transfer-Encoding 标头。
    【解决方案2】:
    1. 失败的http请求的以下参数的状态是什么:

      • 对 HTTP POST 使用 multipart/form-data
      • 浏览器兼容的标头
    2. 您的测试计划中的其他地方没有任何 HTTP 标头管理器实例,是吗?好像是的,它可能会干扰,因为 HTTP 标头管理器的范围不仅限于一个采样器,仅当它没有作为子项添加时。

    3. 您的发布请求详细信息与文件上传请求不同。查看Upload and Download Scenarios with Apache JMeter 指南,看看您是否遗漏了任何重要内容。

    4. 切勿在同一台机器上运行负载生成器和被测应用程序。即使在开发或调试您的测试时。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      相关资源
      最近更新 更多