无法在Gatling中设置正确的BodyPart标头

时间:2016-05-24 11:16:10

标签: scala gatling

我有以下情景

exec(
        http("Request to endpoint: file")
          .post("http://localhost:8378/endpoint")
          .headers(Map(
            "Authorization" -> "Bearer ${access_token}"
          ))
          .bodyPart(StringBodyPart("text_param", "text_value"))
          .bodyPart(RawFileBodyPart("file", "image.png")
            .contentType("application/octet-stream")
            .header("content-length", "35260")
          ).asMultipartForm
          .check(status.is(200))
      )

而且,我得到了'文件'正文部分

的标题

enter image description here

预期:content-length => 35260

实际:content-length35260

2 个答案:

答案 0 :(得分:1)

好吧,我刚收到答案/ workaroung:你需要在内容长度之后添加冒号

.header(“content-length:”,“35260”)

更新:正如Gatling Corporation首席执行官Stephane Landelle所提到的,这是HttpAsyncClient的错误

https://github.com/AsyncHttpClient/async-http-client/issues/1168

因此,如果您可以更新您的依赖项 - >使用Gatling版本> 2.2.0。在其他情况下(我使用2.2.0版本),你可以像我写的一样使用它。

答案 1 :(得分:1)

这是AsyncHttpClient中的一个错误:https://github.com/AsyncHttpClient/async-http-client/issues/1168

为了记录,AHC 2.0.4已经发布了修复程序。