3 ms·
urllib3 lead maintainer here. I wasn't able to reproduce your bug, at least with the main development branch, when I passed `Accept` as part of the `headers` di
by haikuginger 9y ago
urllib3 lead maintainer here. I wasn't able to reproduce your bug, at least with the main development branch, when I passed `Accept` as part of the `headers` dict. If you could file an issue with a reproduction case, I'd definitely appreciate it.
- UncleEntity 9y agoSeems like the problem is due to the way they filter on User-Agent and not with urllib3, sorry.
- UncleEntity 9y agoEh, maybe... http = urllib3.PoolManager() r = http.request('GET', "https://oneom.tk/data/config" https://oneom.tk/data/config", headers={'Accept': 'application/json', 'User-Agent' : "Mozilla/5.0"}) r.headers['Content-Type'] 'application/json' r = http.request('GET', "https://oneom.tk/data/config" https://oneom.tk/data/config", headers={'Accept': 'application/json'}) r.headers['Content-Type'] 'text/html; charset=UTF-8'
- haikuginger 9y agoIt looks like this API in particular expects all requests to have a User-Agent header, and we don't set one by default. Setting any user agent appears to work; the issue isn't with the `Accept` header. You can reproduce with curl with the following command: curl -v 'https://oneom.tk/data/config' -H 'Accept: application/json' -H 'User-Agent:' That'll nullify the default curl user agent and should produce the same results you were seeing with urllib3.
- UncleEntity 9y agoThat makes sense, I kind of figured they were doing something screwy. I'm guessing a blacklist on certain User-Agent settings. When I was messing with it I could get it to work with curl and (eventually) urllib but urllib3 was no bueno until I tried to reproduce the problem and just copied the header with the User-Agent field from the urllib code.