Build Python 3's urllib opener with both the proxy route and protocol handlers whose debug level is enabled:

from urllib.request import (
    HTTPHandler, HTTPSHandler, ProxyHandler, build_opener,
)

opener = build_opener(
    ProxyHandler({
        'http': 'http://proxy.example:8080',
        'https': 'http://proxy.example:8080',
    }),
    HTTPHandler(debuglevel=1),
    HTTPSHandler(debuglevel=1),
)
with opener.open('https://www.example.com/', timeout=10) as response:
    print(response.status)

HTTPHandler and HTTPSHandler expose the tracing option. ProxyHandler supplies the route; it is not where this protocol debug setting belongs. The public request shown can use an unauthenticated address from the HTTP proxy list when public intermediaries are allowed; keep cookies and account tokens out of this diagnostic comparison.

The underlying http.client debug output is printed to standard output. It can show sent request bytes and received response headers, which helps locate a proxy challenge, a tunnel refusal or a later destination response.

Use a controlled request and keep credentials, cookies and tokens out of shared trace output.

Tënë sô zo