{"action":"created","issue":{"url":"https://api.github.com/repos/kennethreitz/requests/issues/2564","labels_url":"https://api.github.com/repos/kennethreitz/requests/issues/2564/labels{/name}","comments_url":"https://api.github.com/repos/kennethreitz/requests/issues/2564/comments","events_url":"https://api.github.com/repos/kennethreitz/requests/issues/2564/events","html_url":"https://github.com/kennethreitz/requests/issues/2564","id":70462809,"number":2564,"title":"requests (2.6.1) sometimes does not decompress gzip-encoded content","user":{"login":"convexset","id":1677933,"avatar_url":"https://avatars.githubusercontent.com/u/1677933?v=3","gravatar_id":"","url":"https://api.github.com/users/convexset","html_url":"https://github.com/convexset","followers_url":"https://api.github.com/users/convexset/followers","following_url":"https://api.github.com/users/convexset/following{/other_user}","gists_url":"https://api.github.com/users/convexset/gists{/gist_id}","starred_url":"https://api.github.com/users/convexset/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/convexset/subscriptions","organizations_url":"https://api.github.com/users/convexset/orgs","repos_url":"https://api.github.com/users/convexset/repos","events_url":"https://api.github.com/users/convexset/events{/privacy}","received_events_url":"https://api.github.com/users/convexset/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-23T17:08:46Z","updated_at":"2015-04-23T17:30:49Z","closed_at":null,"body":"I've been trying out the DigitalOcean API when I encountered the following \"problem\" with requests (2.6.1):\r\n\r\n    token = \"xxxxxxxxxxxxxx\"\r\n    api = \"/account/keys\"\r\n    headers = {\"Content-Type\": \"application/json\", \"Authorization\": \"Bearer \"+token}\r\n    r = requests.get(\"https://api.digitalocean.com/v2/\"+api, headers=headers, data=data)\r\n\r\n... results in output for r.content and r.text like...\r\n\r\n    '\\x1f\\x8b\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\x03mR\\xd9\\xae\\xa2@\\x14\\xfc\\x95\\x9b~\\xd5\\x19\\x96\\x06\\x81Nn2(^\\x14\\x95\\xc5\\x05\\xc5\\xc9d\\xd2t\\xb7\\n\\xb2\\xc9\\xa6h\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xbc\\xbcN\\xac\\xbbAg~\\xd6\\xb9\\xf3\\xa2VI\\xf2\\x9c\\x04\\x85\\xe2\\xac\\x8e\\xcc\\x91\\xac\\xf95\\xc8}u\\x93\\\\v\\xb6Wp\\x0f\\x9a?,\\x0f\\x87\\xcb4\\x0e\\xdc\\xaea\\x99\\xfe\\xb5=\\xcd\\x99S\\xb5j\\xa9\\xdc;\\xeex\\xff\\xfc\\xfc y\\xd6\\xb2G\\xc5\\xea\\x1f\\xe7\\x14G\\xc9w\\x92\\xa7}?\\x19NY\\xdf\\xcc\\xff\\x8e\\xef_C\\x90D\\xd9\\xb5\\x7f\\x8a\\xd7{\\x08RV\\xe3\\x1e\\x81:\\xafq\\x02\\x90\\xf0~\\xff\\x01T\\xdb#\\x867\\x02\\x00\\x00'\r\n\r\n... which has to be ameliorated with...\r\n\r\n    import zlib\r\n    data = zlib.decompress(r.content, 16+zlib.MAX_WBITS)\r\n\r\n... because `r.headers['content-encoding']` happens to be `'gzip'`.\r\n\r\nIt may be good to detect gzip and other compressive encodings and proactively decompress it. Or have a default option to decompress (because in some applications, premature decompression is undesirable).\r\n\r\nBut all this seems a bit unusual because the documentation says that \"*Requests automatically decompresses gzip-encoded responses, and does its best to decode response content to unicode when possible.*\" \r\n\r\nSame thing happens on CentOS Linux release 7.0.1406 (Core) (Python Python 2.7.5 via yum; requests 2.6.1) and OS X Yosemite 10.10.2 (Python 2.7.9 via Brew; requests 2.6.1)."},"comment":{"url":"https://api.github.com/repos/kennethreitz/requests/issues/comments/95664809","html_url":"https://github.com/kennethreitz/requests/issues/2564#issuecomment-95664809","issue_url":"https://api.github.com/repos/kennethreitz/requests/issues/2564","id":95664809,"user":{"login":"sigmavirus24","id":240830,"avatar_url":"https://avatars.githubusercontent.com/u/240830?v=3","gravatar_id":"","url":"https://api.github.com/users/sigmavirus24","html_url":"https://github.com/sigmavirus24","followers_url":"https://api.github.com/users/sigmavirus24/followers","following_url":"https://api.github.com/users/sigmavirus24/following{/other_user}","gists_url":"https://api.github.com/users/sigmavirus24/gists{/gist_id}","starred_url":"https://api.github.com/users/sigmavirus24/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigmavirus24/subscriptions","organizations_url":"https://api.github.com/users/sigmavirus24/orgs","repos_url":"https://api.github.com/users/sigmavirus24/repos","events_url":"https://api.github.com/users/sigmavirus24/events{/privacy}","received_events_url":"https://api.github.com/users/sigmavirus24/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T17:30:49Z","updated_at":"2015-04-23T17:30:49Z","body":"This is a duplicate of #2561 (or #2562 - I'm on my phone and can't check). Upgrading to v2.6.2 will fix this."}}