Locust: 【Question】How can I send https request with locust?

Created on 2 Sep 2016  ·  5Comments  ·  Source: locustio/locust

As title.

Most helpful comment

For people who actually have to make HTTPS requests with certs,
note that x.client.post, x.client.get, etc.. wraps around requests:

def post(self, url, data=None, json=None, **kwargs): Sends a POST request. Returns :class:Response` object.

    :param url: URL for the new :class:`Request` object.
    :param data: (optional) Dictionary, list of tuples, bytes, or file-like
        object to send in the body of the :class:`Request`.
    :param json: (optional) json to send in the body of the :class:`Request`.
    :param \*\*kwargs: Optional arguments that ``request`` takes.
    :rtype: requests.Response
   `

so just simply do the following:

l.client.post("/login", {"username":"someuser", "password":"somepassword"}, cert=(PATH_TO_MY_CERT, PATH_TO_MY_KEY_FILE), verify=PATH_TO_CA_BUNDLE_OR_FALSE)

Note that cert=

All 5 comments

Read the documentation (http://docs.locust.io). You can start here: http://docs.locust.io/en/latest/quickstart.html

That is a totally useless answer. This is a nontrivial question, you could at least point to a more specific page; at first sight, Locust only allows to test against HTTP.
http://docs.locust.io/en/latest/search.html?q=https&check_keywords=yes&area=default

this is probably the best a user can use, and still unusable:
http://docs.locust.io/en/latest/testing-other-systems.html

Locust only allows to test against HTTP

completely false.

I know this is an old post, but this did it for me.

For people who actually have to make HTTPS requests with certs,
note that x.client.post, x.client.get, etc.. wraps around requests:

def post(self, url, data=None, json=None, **kwargs): Sends a POST request. Returns :class:Response` object.

    :param url: URL for the new :class:`Request` object.
    :param data: (optional) Dictionary, list of tuples, bytes, or file-like
        object to send in the body of the :class:`Request`.
    :param json: (optional) json to send in the body of the :class:`Request`.
    :param \*\*kwargs: Optional arguments that ``request`` takes.
    :rtype: requests.Response
   `

so just simply do the following:

l.client.post("/login", {"username":"someuser", "password":"somepassword"}, cert=(PATH_TO_MY_CERT, PATH_TO_MY_KEY_FILE), verify=PATH_TO_CA_BUNDLE_OR_FALSE)

Note that cert=

Was this page helpful?
0 / 5 - 0 ratings