小编Sof*_*fia的帖子

使用Gatling和Content-Type进行负载性能测试

我正在使用gatling在一个全新的API上进行负载性能测试.这看起来相当容易并且有很好的文档记录,但是我遇到的问题很简单,就像将一个请求的内容类型设置为Header上的'application/vnd.api + json'一样简单.在进行GET操作时一切正常,但在启动POST测试时,我得到了一个

HTTP response:
status=
415 Unsupported Media Type
headers= 
cache-control: [no-cache]
Content-Type: [application/vnd.api+json; charset=utf-8]
Date: [Fri, 08 Sep 2017 12:57:10 GMT]
Server: [nginx]
Vary: [Origin]
x-content-type-options: [nosniff]
x-frame-options: [SAMEORIGIN]
X-Request-Id: [ff993645-8e01-4689-82a8-2f0920e4f2a9]
x-runtime: [0.040662]
x-xss-protection: [1; mode=block]
Content-Length: [218]
Connection: [keep-alive]

body=
{"errors":[{"title":"Unsupported media type","detail":"All requests that create or update must use the 'application/vnd.api+json' Content-Type. This request specified 'application/json'.","code":"415","status":"415"}]}
Run Code Online (Sandbox Code Playgroud)

这是我用于http请求的scala代码:

object PostTokenGcm {
 val token = exec {
  http("TestAPI POST /tokens")
    .post("/tokens")
    .headers(Map("Authorization" -> testApiToken,
       "Content-Type" -> "application/vnd.api+json",
        "Accept" …
Run Code Online (Sandbox Code Playgroud)

scala gatling scala-gatling

7
推荐指数
1
解决办法
803
查看次数

标签 统计

gatling ×1

scala ×1

scala-gatling ×1