Full Debug / Dump of a Request
See original GitHub issueIs there any functionality that replicates dump from requests_toolbelt.utils , that dumps out full headers and content etc from the response so you can debug your requests… as I cannot find any reference to debugging in the documentation…
IE in requests
import requests
from requests_toolbelt.utils import dump
def debugRequest(req):
try:
print(dump.dump_all(req).decode('utf-8'))
except: # noqa
pass
ret = requests.get('http://example.com')
debugRequest(ret)
Would result in…
< GET / HTTP/1.1
< Host: example.com
< User-Agent: python-requests/2.22.0
< Accept-Encoding: gzip, deflate
< Accept: */*
< Connection: keep-alive
<
> HTTP/1.1 200 OK
> Content-Encoding: gzip
> Accept-Ranges: bytes
> Cache-Control: max-age=604800
> Content-Type: text/html; charset=UTF-8
> Date: Mon, 09 Sep 2019 21:02:17 GMT
> Etag: "1541025663"
> Expires: Mon, 16 Sep 2019 21:02:17 GMT
> Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
> Server: ECS (oxr/830D)
> Vary: Accept-Encoding
> X-Cache: HIT
> Content-Length: 606
>
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
background-color: #f0f0f2;
margin: 0;
padding: 0;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
div {
width: 600px;
margin: 5em auto;
padding: 50px;
background-color: #fff;
border-radius: 1em;
}
a:link, a:visited {
color: #38488f;
text-decoration: none;
}
@media (max-width: 700px) {
body {
background-color: #fff;
}
div {
width: auto;
margin: 0 auto;
border-radius: 0;
padding: 1em;
}
}
</style>
</head>
<body>
<div>
<h1>Example Domain</h1>
<p>This domain is established to be used for illustrative examples in documents. You may use this
domain in examples without prior coordination or asking for permission.</p>
<p><a href="http://www.iana.org/domains/example">More information...</a></p>
</div>
</body>
</html>
Cheers
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Use dump files in the debugger - Visual Studio - Microsoft Learn
A dump file is a snapshot of an executing app and loaded modules. Consider creating a dump file for situations where you don't...
Read more >How can I see the entire HTTP request that's being sent by my ...
A simple method: enable logging in recent versions of Requests (1.x and higher.) Requests uses the http.client and logging module configuration to control ......
Read more >How to Create, Use, and Debug .NET application Crash ...
Open the Task Manager, go to Details, right-click the desired process and choose Create dump file. This will create a full memory dump....
Read more >Debug & Analyze Dump Files in Visual Studio - YouTube
Not sure what to do when an unexpected crash occurs in your application? Try opening a memory dump file! Join us in a...
Read more >Dump Analysis - Debugging a Multi-Process Hang
Dump Analysis - Debugging a Multi-Process Hang. This article walks through the analysis of an application hang caused by a chain of RPC...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This wouldn’t be too hard to implement. IMO we should look to requests-toolbelt for inspiration on how some functionality like multipart form encoding to work like that by default. Toolbelt is basically Requests+
Not sure about this exact feature but some of them might be good for us.
Closing this as out-of-scope to the core package. We’re tracking the middleware API in #345, which is also somewhat relevant.