{"action":"created","issue":{"url":"https://api.github.com/repos/valyala/fasthttp/issues/150","repository_url":"https://api.github.com/repos/valyala/fasthttp","labels_url":"https://api.github.com/repos/valyala/fasthttp/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/valyala/fasthttp/issues/150/comments","events_url":"https://api.github.com/repos/valyala/fasthttp/issues/150/events","html_url":"https://github.com/valyala/fasthttp/pull/150","id":168128537,"number":150,"title":"Proof of Concept: handling huge/endless response body","user":{"login":"aspcartman","id":844194,"avatar_url":"https://avatars.githubusercontent.com/u/844194?v=3","gravatar_id":"","url":"https://api.github.com/users/aspcartman","html_url":"https://github.com/aspcartman","followers_url":"https://api.github.com/users/aspcartman/followers","following_url":"https://api.github.com/users/aspcartman/following{/other_user}","gists_url":"https://api.github.com/users/aspcartman/gists{/gist_id}","starred_url":"https://api.github.com/users/aspcartman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspcartman/subscriptions","organizations_url":"https://api.github.com/users/aspcartman/orgs","repos_url":"https://api.github.com/users/aspcartman/repos","events_url":"https://api.github.com/users/aspcartman/events{/privacy}","received_events_url":"https://api.github.com/users/aspcartman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-28T15:42:24Z","updated_at":"2016-07-28T16:03:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/valyala/fasthttp/pulls/150","html_url":"https://github.com/valyala/fasthttp/pull/150","diff_url":"https://github.com/valyala/fasthttp/pull/150.diff","patch_url":"https://github.com/valyala/fasthttp/pull/150.patch"},"body":"Not to be merged yet, PoC only.\r\nIt's done by setting a flag `HandlingBodyManually` (new) into `Request`. If it's set, then the `HostClient` disables automatic response body fetch for the response by setting `SkipBody` flag on the response in it's `Do`. Then it sets a `manualBodyReadAccessor` in the response, which is to be used by user to read the data.\r\n\r\nAs the result, it's impossible to release/close resources used (the reader and the connection) inside the `doNonNilReqResp()` since they are needed to read data afterward, they leak outside.\r\n\r\n `manualBodyReadAccessor` holds references to and is responsible to release:\r\n1. The `buffered reader` that had been used for reading the response header in the first place. It's the data source off which the user is meant to read data. As I get it, there is no way to throw the one away and acquire a new one later: it may have already pulled some parts of data out of the connection and buffered it.\r\n2. The connection (for releasing).\r\n3. ShouldClose flag: should it close the connection or just release one.\r\n4. HostClient to release resources to it.\r\n\r\nUsage:\r\n```go\r\n\treq.HandlingBodyManually = true\r\n\t_ = fasthttp.Do(req, resp)\r\n\tr := resp.ManualBodyReader()\r\n\tfor {\r\n\t\t// r is io.ReadCloser, pass it around, read, do stuff.\r\n\t}\r\n\t_ = r.Close()\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/valyala/fasthttp/issues/comments/235941603","html_url":"https://github.com/valyala/fasthttp/pull/150#issuecomment-235941603","issue_url":"https://api.github.com/repos/valyala/fasthttp/issues/150","id":235941603,"user":{"login":"aspcartman","id":844194,"avatar_url":"https://avatars.githubusercontent.com/u/844194?v=3","gravatar_id":"","url":"https://api.github.com/users/aspcartman","html_url":"https://github.com/aspcartman","followers_url":"https://api.github.com/users/aspcartman/followers","following_url":"https://api.github.com/users/aspcartman/following{/other_user}","gists_url":"https://api.github.com/users/aspcartman/gists{/gist_id}","starred_url":"https://api.github.com/users/aspcartman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspcartman/subscriptions","organizations_url":"https://api.github.com/users/aspcartman/orgs","repos_url":"https://api.github.com/users/aspcartman/repos","events_url":"https://api.github.com/users/aspcartman/events{/privacy}","received_events_url":"https://api.github.com/users/aspcartman/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T16:03:08Z","updated_at":"2016-07-28T16:03:08Z","body":"I think I came up with a thought: what if to leave `Response` alone and work with `HostClient`: make it `io.ReadCloser`? Or add a new Do method, which returns a similar to `manualBodyReadAccessor` `io.ReadCloser`? Opinions?"}}
{"actor":{"display_login":"aspcartman"}}