Categories
Python Answers

How to see the entire HTTP request that’s being sent with Python?

Spread the love

Sometimes, we want to see the entire HTTP request that’s being sent with Python.

In this article, we’ll look at how to see the entire HTTP request that’s being sent with Python.

How to see the entire HTTP request that’s being sent with Python?

To see the entire HTTP request that’s being sent with Python, we can use the requests module.

For instance, we write

r = requests.get('https://api.github.com', auth=('user', 'pass'))

to make a GET request.

We can get the request content from r.request.

And we can get the request headers with r.request.headers.

And we can get the request body data with r.request.data.

Conclusion

To see the entire HTTP request that’s being sent with Python, we can use the requests module.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *