Skip to main content

Convert requests.Response into a string representing an HTTP-request and its response

Project description

requests-verbose

Convert requests.Response object into a string representing an HTTP request and response. It comes in handy when doing verbose debug-logging for requests.

Usage

import requests
from requests_verbose import http_str
resp = requests.get("https://raw.githubusercontent.com/python/peps/refs/heads/main/peps/pep-0020.rst")
print(http_str(resp, body_size_limit_bytes=0))

Results in:

HTTP Request
GET https://raw.githubusercontent.com/python/peps/refs/heads/main/peps/pep-0020.rst HTTP/11
> User-Agent: python-requests/2.32.3
> Accept-Encoding: gzip, deflate
> Accept: */*
> Connection: keep-alive

<NO BODY>

HTTP Response
https://raw.githubusercontent.com/python/peps/refs/heads/main/peps/pep-0020.rst HTTP/11
< Connection: keep-alive
< Content-Length: 891
< Cache-Control: max-age=300
< Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
< Content-Type: text/plain; charset=utf-8
< ETag: W/"7488b1a4236ea135e37614a1865fe92f1ad29f6f2bfde5aa9fbee59f18a58a61"
< Strict-Transport-Security: max-age=31536000
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-XSS-Protection: 1; mode=block
< X-GitHub-Request-Id: F68F:4E53C:8963C11:8F181B5:67784A69
< Content-Encoding: gzip
< Accept-Ranges: bytes
< Date: Fri, 03 Jan 2025 20:38:52 GMT
< Via: 1.1 varnish
< X-Served-By: cache-vie6340-VIE
< X-Cache: HIT
< X-Cache-Hits: 0
< X-Timer: S1735936733.781834,VS0,VE7
< Vary: Authorization,Accept-Encoding,Origin
< Access-Control-Allow-Origin: *
< Cross-Origin-Resource-Policy: cross-origin
< X-Fastly-Request-ID: 326d7cae8caa6dd4663daa6dda7c037e51f36453
< Expires: Fri, 03 Jan 2025 20:43:52 GMT
< Source-Age: 115

<BODY EXCEEDS LIMIT> (size 1673 bytes, limit 0 bytes)

Help

from requests_verbose import http_str
help(http_str)

Development

# 0. Open a GitHub Issue, ask a question first
# 1. Build and install locally
make dev
# 2. Make changes
# 3. Before commiting
make format
make check
# 4. Commit and open a Pull Request

License

See LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

requests_verbose-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file requests_verbose-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for requests_verbose-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19db6753672260854e633a92726e55fc7417c9639c31871601f43c39db525384
MD5 5a6741644e90340658fcc8b9e027f7fc
BLAKE2b-256 e713a0056407f7892f2d40e9cbaf2190117a2de14e40004cd2b5149b5b2283ba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page