0

I'm new to locust, and I know it has a good support for http request in json format.

We want to perform stress test on a http api with pb format, but, how to send http request in protobuf format by locust (instead, jmeter supports pb format).

Is this the same with uploading file?

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

r = requests.post('http://localhost:5000/', files=files)
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Ning Lv
  • 35
  • 1
  • 5

1 Answers1

0

It depends on how the server expects the data to get transfered. If it expects it to be transfered as a multipart file upload you would use the files keyword argument (http://docs.python-requests.org/en/master/user/quickstart/#post-a-multipart-encoded-file). However, if I would guess, I would think that it's more likely that the data were to be transfered as raw data in the POST body:

self.client.post("/some/url", data=my_protobuf_data)
heyman
  • 4,845
  • 3
  • 26
  • 19