{"action":"created","issue":{"url":"https://api.github.com/repos/shazow/urllib3/issues/709","labels_url":"https://api.github.com/repos/shazow/urllib3/issues/709/labels{/name}","comments_url":"https://api.github.com/repos/shazow/urllib3/issues/709/comments","events_url":"https://api.github.com/repos/shazow/urllib3/issues/709/events","html_url":"https://github.com/shazow/urllib3/issues/709","id":107232759,"number":709,"title":"When .read has an amount specified it should be the post-decode amount","user":{"login":"gilesbrown","id":450406,"avatar_url":"https://avatars.githubusercontent.com/u/450406?v=3","gravatar_id":"","url":"https://api.github.com/users/gilesbrown","html_url":"https://github.com/gilesbrown","followers_url":"https://api.github.com/users/gilesbrown/followers","following_url":"https://api.github.com/users/gilesbrown/following{/other_user}","gists_url":"https://api.github.com/users/gilesbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/gilesbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilesbrown/subscriptions","organizations_url":"https://api.github.com/users/gilesbrown/orgs","repos_url":"https://api.github.com/users/gilesbrown/repos","events_url":"https://api.github.com/users/gilesbrown/events{/privacy}","received_events_url":"https://api.github.com/users/gilesbrown/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-09-18T16:16:58Z","updated_at":"2015-09-29T18:21:50Z","closed_at":null,"body":"I have some code that does a partial read of a \"raw\" response in requests to look for \"magic bytes\".  Digging into the urllib3 code I find that the size you pass in is used as the pre-decode amount which means that the decompressor doesn't have enough bytes to give you anything.  This confused my code into thinking it had read all of the response, which it hadn't.\r\n\r\nHere is a simple example:\r\n\r\nIn [1]: import urllib3\r\nIn [2]: http = urllib3.PoolManager()\r\nIn [3]: resp = http.request('GET', 'http://httpbin.org/gzip')\r\nIn [4]: resp.read(8)\r\nOut[4]: b''\r\n\r\nI would argue that the amount passed into .read (8 in this case) should be the amount *after* decoding.\r\n\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/26787567-when-read-has-an-amount-specified-it-should-be-the-post-decode-amount?utm_campaign=plugin&utm_content=tracker%2F192525&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F192525&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/shazow/urllib3/issues/comments/144145073","html_url":"https://github.com/shazow/urllib3/issues/709#issuecomment-144145073","issue_url":"https://api.github.com/repos/shazow/urllib3/issues/709","id":144145073,"user":{"login":"gilesbrown","id":450406,"avatar_url":"https://avatars.githubusercontent.com/u/450406?v=3","gravatar_id":"","url":"https://api.github.com/users/gilesbrown","html_url":"https://github.com/gilesbrown","followers_url":"https://api.github.com/users/gilesbrown/followers","following_url":"https://api.github.com/users/gilesbrown/following{/other_user}","gists_url":"https://api.github.com/users/gilesbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/gilesbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gilesbrown/subscriptions","organizations_url":"https://api.github.com/users/gilesbrown/orgs","repos_url":"https://api.github.com/users/gilesbrown/repos","events_url":"https://api.github.com/users/gilesbrown/events{/privacy}","received_events_url":"https://api.github.com/users/gilesbrown/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T18:21:50Z","updated_at":"2015-09-29T18:21:50Z","body":"Well I am going to note that I consider the current behaviour is a bug.  This behaviour can silently fail on people in an unexpected way (as it did with me).\r\n\r\nBut I'll leave it open to you folks to decide.  FWIW I'm not particularly interested in writing a PULL request for a non-mainstream piece of functionality.  In that case I'll just settle with leaving the code in Wextracto.  Sorry if that sounds belligerent but you now life is too short right? :) "}}