URLFetch adds gzip,deflate,br to outbound requests' Accept-Encoding?

117 views
Skip to first unread message

Ryan B

unread,
Aug 2, 2018, 5:50:51 PM8/2/18
to Google App Engine
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.

is this expected? it's not documented on https://cloud.google.com/appengine/docs/standard/python/outbound-requests#request_headers , and brotli support isn't built into many common HTTP libraries, e.g. python requests, so this will usually be an unpleasant surprise when talking to a server that supports brotli. is it unintentional? should i file a bug?

here's a snippet that reproduces this on https://shell-hrd.appspot.com/ :

>>> 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"
  }
}

Ryan B

unread,
Aug 6, 2018, 11:16:21 PM8/6/18
to Google App Engine

Jorge A (Google Cloud Support)

unread,
Aug 9, 2018, 4:00:04 PM8/9/18
to Google App Engine
Since you've filed the issue through the proper channel, we'll continue to look at this through the issue tracker. 
Reply all
Reply to author
Forward
0 new messages