{"action":"created","issue":{"url":"https://api.github.com/repos/neonmoe/minreq/issues/17","repository_url":"https://api.github.com/repos/neonmoe/minreq","labels_url":"https://api.github.com/repos/neonmoe/minreq/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/neonmoe/minreq/issues/17/comments","events_url":"https://api.github.com/repos/neonmoe/minreq/issues/17/events","html_url":"https://github.com/neonmoe/minreq/issues/17","id":492416691,"node_id":"MDU6SXNzdWU0OTI0MTY2OTE=","number":17,"title":"More way to handle response","user":{"login":"hismito","id":42246585,"node_id":"MDQ6VXNlcjQyMjQ2NTg1","avatar_url":"https://avatars2.githubusercontent.com/u/42246585?v=4","gravatar_id":"","url":"https://api.github.com/users/hismito","html_url":"https://github.com/hismito","followers_url":"https://api.github.com/users/hismito/followers","following_url":"https://api.github.com/users/hismito/following{/other_user}","gists_url":"https://api.github.com/users/hismito/gists{/gist_id}","starred_url":"https://api.github.com/users/hismito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hismito/subscriptions","organizations_url":"https://api.github.com/users/hismito/orgs","repos_url":"https://api.github.com/users/hismito/repos","events_url":"https://api.github.com/users/hismito/events{/privacy}","received_events_url":"https://api.github.com/users/hismito/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-09-11T19:10:58Z","updated_at":"2019-09-11T19:58:32Z","closed_at":null,"author_association":"NONE","body":"While considering a breaking change release https://github.com/neonmoe/minreq/issues/13#issuecomment-498053281, it would nice to provide more way to handle response.\r\n\r\nFor now, `minreq` will [read all bytes into memory](https://github.com/neonmoe/minreq/blob/4f7f017246070bbfca237a247eff0936e53c0d96/src/connection.rs#L151) after receiving the response, it's convenient for response that only contains a few lines of text. When requesting a big chunk of data (for example, download a file),  there may be some trouble.\r\n\r\nHow about the `Response` struct holds the [`stream`](https://github.com/neonmoe/minreq/blob/4f7f017246070bbfca237a247eff0936e53c0d96/src/connection.rs#L151) as a field, since the http status line and headers appear before the body, we can still provide them in `Response` as pub fields. Then using dedicated methods to actually decode the body only when needed. \r\n```rust\r\nstruct Response<S> {\r\n    // status fields ...\r\n    stream: S,\r\n}\r\n\r\nimpl<S> Response<S> {\r\n    fn into_string(self) -> Result<String> {}\r\n\r\n    fn into_vec(self) -> Result<Vec<u8>> {}\r\n\r\n    fn into_stream(self) -> S {}\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/neonmoe/minreq/issues/comments/530541321","html_url":"https://github.com/neonmoe/minreq/issues/17#issuecomment-530541321","issue_url":"https://api.github.com/repos/neonmoe/minreq/issues/17","id":530541321,"node_id":"MDEyOklzc3VlQ29tbWVudDUzMDU0MTMyMQ==","user":{"login":"neonmoe","id":22432472,"node_id":"MDQ6VXNlcjIyNDMyNDcy","avatar_url":"https://avatars3.githubusercontent.com/u/22432472?v=4","gravatar_id":"","url":"https://api.github.com/users/neonmoe","html_url":"https://github.com/neonmoe","followers_url":"https://api.github.com/users/neonmoe/followers","following_url":"https://api.github.com/users/neonmoe/following{/other_user}","gists_url":"https://api.github.com/users/neonmoe/gists{/gist_id}","starred_url":"https://api.github.com/users/neonmoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neonmoe/subscriptions","organizations_url":"https://api.github.com/users/neonmoe/orgs","repos_url":"https://api.github.com/users/neonmoe/repos","events_url":"https://api.github.com/users/neonmoe/events{/privacy}","received_events_url":"https://api.github.com/users/neonmoe/received_events","type":"User","site_admin":false},"created_at":"2019-09-11T19:58:32Z","updated_at":"2019-09-11T19:58:32Z","author_association":"OWNER","body":"This is definitely a good idea, I'll have a think about how to go about implementing this in a clean manner. Also, now that the stream is passed around more, I think there's reason to consider switching to a proper type for the stream instead of a generic: it's defined in the crate (so it doesn't give users flexibility), and generics are bad for compile times."}}
{"actor":{"display_login":"neonmoe"}}