Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return_response a valid request argument #229

Closed
ghost opened this issue Jan 16, 2015 · 5 comments
Closed

return_response a valid request argument #229

ghost opened this issue Jan 16, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Jan 16, 2015

Is return_response a valid request argument?

:param return_response: (optional) If False, an un-sent Request object will returned.

TypeError: request() got an unexpected keyword argument 'return_response'

@heyman heyman closed this as completed in 3758794 Jan 16, 2015
@heyman
Copy link
Member

heyman commented Jan 16, 2015

No, it's not. Good catch!

Since Locust mostly wraps python-requests, part of that docstring had been copied from requests. Requests has changed it's method signature in later versions which Locust has upgraded to, without updating the docstring.

Thanks!

@ghost
Copy link
Author

ghost commented Jan 16, 2015

Hi @heyman

Is it possible to log the requests being sent in locust or do I need to drop down to python-requests?

@ghost
Copy link
Author

ghost commented Jan 16, 2015

  with self.client.get("/", catch_response=True) as response:
            print response.request.headers

@heyman
Copy link
Member

heyman commented Jan 16, 2015

Do you want to print log something for every request? There's different ways to go about that, but you shouldn't need to modify either locust nor python-requests.

For example, you could add a get method on your Locust class, which prints something and then calls self.client.get(). Something like this:

class MyLocust(HttpLocust):
    def get(self, *args, **kwargs):
        response = self.client.get(*args, **kwargs)
        print response.headers
        return response

Then you'd have to update so that you'd use that method for making requests instead of self.client.get. If you don't want to do that, you could also make some kind of proxy object which you replace the client attribute with.

@ghost
Copy link
Author

ghost commented Jan 16, 2015

@heyman Thanks for the advice. I just wanted to ensure the correct headers were being sent in the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant