简体   繁体   中英

How to send http request in protobuf format by locust

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)

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM