我打算从Ruby on Rails应用程序调用:
c = Curl::Easy.http_post("https://example.com", json_string_goes_here) do |curl|
curl.headers['Accept'] = 'application/json'
curl.headers['Content-Type'] = 'application/json'
curl.headers['Api-Version'] = '2.2'
end
Run Code Online (Sandbox Code Playgroud)
响应应该有自定义标头:
X-Custom1 : "some value"
X-Custom2 : "another value"
Run Code Online (Sandbox Code Playgroud)
如何迭代响应头以将值与我期望的值进行比较?
我打算发送如下请求:
c = Curl::Easy.http_post("https://example.com", json_string
) do |curl|
curl.headers['Accept'] = 'application/json'
curl.headers['Content-Type'] = 'application/json'
curl.headers['Api-Version'] = '2.2'
end
Run Code Online (Sandbox Code Playgroud)
我想记录正在进行的确切http请求.有没有办法获得所做的实际请求(基本路径,查询参数,标题和正文)?
我是加特林的新手。我正在尝试使用Gatling将POST消息发送到HTTP API。我尝试了以下方法:
package app.basic
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class basicPost extends Simulation {
val headers_10 = Map("Content-Type" -> """application/json""")
object Post {
// repeat is a loop resolved at RUNTIME
val post = repeat(50) {
exec(http("Post Data")
.post("/data")
.queryParam("""size""", "10"))
.headers(headers_10)
.body("""{"id1":"0000000000"}""")
.pause(1)
}
}
val httpConf = http.baseURL("http://amazonperf-env.elasticbeanstalk.com")
val users = scenario("Users").exec(Post.post)
setUp(
users.inject(rampUsers(1000) over (10 seconds))
).protocols(httpConf)
}
Run Code Online (Sandbox Code Playgroud)
但是,在编译时出现此错误:值主体不是io.gatling.core.structure.ChainBuilder的成员可能的原因:可能在“值主体”之前缺少分号?
如何指定要发送的邮件正文?