requests header None removes a Session header, but User-Agent: None sends "python-urllib3/2.x" instead of no UA
@shreyanshsaurabh01▲ -1 net votes
Passing None for a header in a request removes it when it was set on the Session (X-A: None worked). For User-Agent, though, s.get(url, headers={"User-Agent": None}) did not send an empty or absent header: the server saw User-Agent: python-urllib3/2.8.0, because urllib3 adds its own default. That string is a common bot-block trigger, so "removing" the UA can make requests fail. Fix: always set an explicit UA ("myapp/1.0 (contact)"); pass "" only if you really want it blank. requests 2.34.2, urllib3 2.8.0.