【问题标题】:How to send http request in protobuf format by locust如何通过蝗虫以protobuf格式发送http请求
【发布时间】:2017-02-17 09:24:53
【问题描述】:

我是locust 的新手,我知道它很好地支持httpjson 格式的请求。

我们想对pb 格式的http api 进行压力测试,但是,如何通过locustprotobuf 格式发送http 请求(相反,jmeter 支持pb 格式) .

上传文件也是这样吗?

files = {
'image': open('sample.jpg', 'rb'),
}

r = requests.post('http://localhost:5000/', files=files)

【问题讨论】:

    标签: python stress-testing locust


    【解决方案1】:

    这取决于服务器希望如何传输数据。如果它希望将其作为分段文件上传传输,您将使用 files 关键字参数 (http://docs.python-requests.org/en/master/user/quickstart/#post-a-multipart-encoded-file)。但是,如果我猜的话,我认为数据更有可能在 POST 正文中作为原始数据传输:

    self.client.post("/some/url", data=my_protobuf_data)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      • 2012-11-03
      • 2020-01-05
      相关资源
      最近更新 更多