Ability to not send a user-agent header at all #1566
-
Airtable appear to have blocked access to their API from the default HTTPX user-agent, possibly because a bunch of people have been using my completely legitimate, non-abusive Airtable backup script built on HTTPX: https://github.com/simonw/airtable-export Rather than playing cat-and-mouse with different user-agents, I'd like to just not send a user-agent at all. Is there a way to do that with HTTPX? This doesn't quite work, it sends the header with an empty string instead: >>> httpx.get("https://httpbin.org/headers", headers={"user-agent": ""}).json()
{'headers': {'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Host': 'httpbin.org',
'User-Agent': '',
'X-Amzn-Trace-Id': 'Root=1-6071c2cf-74cc2e6f2e2792bf08e8c70b'}} Ideally I'd like to be able to do something like this, but it currently throws an error: >>> httpx.get("https://httpbin.org/headers", headers={"user-agent": None}).json()
AttributeError: 'NoneType' object has no attribute 'encode' |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hiya Simon, So we do provide that functionality, but not with the top-level API. Instead you'd need to do this... client = httpx.Client()
del client.headers["user-agent"]
client.get(...) |
Beta Was this translation helpful? Give feedback.
-
I'll use the workaround for now, but I'm also interested in this! |
Beta Was this translation helpful? Give feedback.
Hiya Simon,
So we do provide that functionality, but not with the top-level API.
Instead you'd need to do this...