File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11"""High-level HTTP GET using urllib (Python stdlib).
22
33Demonstrates that Python's standard urllib.request module works
4- over the host-proxied socket layer — no raw sockets needed.
5-
6- Uses a raw IP with Host header to avoid DNS dependency (glibc's
7- getaddrinfo doesn't yet work over host-proxied UDP sockets).
4+ over the host-proxied socket layer with full DNS resolution.
85"""
96import urllib .request
107import sys
118
12- URL = "http://172.66.147.243 /"
9+ URL = "http://example.com /"
1310
1411print (f"Fetching { URL } ..." )
15- req = urllib .request .Request (URL , headers = {"Host" : "example.com" })
1612try :
17- with urllib .request .urlopen (req , timeout = 10 ) as resp :
13+ with urllib .request .urlopen (URL , timeout = 10 ) as resp :
1814 body = resp .read ().decode ("utf-8" , errors = "replace" )
1915 print (f"Status: { resp .status } " )
2016 print (f"Body length: { len (body )} bytes" )
You can’t perform that action at this time.
0 commit comments