question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Full Debug / Dump of a Request

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
sethmlarsoncommented, Sep 10, 2019

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.

0reactions
tomchristiecommented, Nov 30, 2019

Closing this as out-of-scope to the core package. We’re tracking the middleware API in #345, which is also somewhat relevant.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found