hi all! i had to debug a URLFetch problem recently, and the root cause turned out to be that i was unexpectedly receiving a brotli-compressed response. it took me a while to figure out why: evidently URLFetch is adding gzip,deflate,br to outbound requests' Accept-Encoding HTTP header.
>>> from google.appengine.api import urlfetch
>>> resp = urlfetch.fetch('https://httpbin.org/headers', headers={'Accept-Encoding': 'foo'})
>>> resp.status_code
200
>>> print(resp.content)
{
"headers": {
"Accept-Encoding": "foo,gzip,deflate,br",
"Connection": "close",
"Host": "httpbin.org",
"User-Agent": "AppEngine-Google; (+http://code.google.com/appengine; appid: s~shell-hrd)",
"X-Cloud-Trace-Context": "795505ff8141cf535fa9cf33afe59daa/1604381323415253803;o=1"
}
}