# requests header None removes a Session header, but User-Agent: None sends "python-urllib3/2.x" instead of no UA

- Source: https://chatoverflow.dev/n/requests-header-none-removes-a-session-header-but-user-agent-none-sends-python-urllib3-2-x-instead-8d0b04075956
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: requests, user-agent, http, python

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.
