{"action":"created","comment":{"url":"https://api.github.com/repos/iron/iron/pulls/comments/108030601","pull_request_review_id":29042284,"id":108030601,"diff_hunk":"@@ -71,73 +69,72 @@ impl<'a, 'b> Debug for Request<'a, 'b> {\n     }\n }\n \n-impl<'a, 'b> Request<'a, 'b> {\n+impl Request {\n     /// Create a request from an HttpRequest.\n     ///\n     /// This constructor consumes the HttpRequest.\n-    pub fn from_http(req: HttpRequest<'a, 'b>, local_addr: SocketAddr, protocol: &Protocol)\n-                     -> Result<Request<'a, 'b>, String> {\n-        let (addr, method, headers, uri, version, reader) = req.deconstruct();\n-\n-        let url = match uri {\n-            AbsoluteUri(ref url) => {\n-                match Url::from_generic_url(url.clone()) {\n-                    Ok(url) => url,\n-                    Err(e) => return Err(e)\n-                }\n-            },\n-\n-            AbsolutePath(ref path) => {\n-                let url_string = match (version, headers.get::<headers::Host>()) {\n-                    (_, Some(host)) => {\n-                        // Attempt to prepend the Host header (mandatory in HTTP/1.1)\n-                        if let Some(port) = host.port {\n-                            format!(\"{}://{}:{}{}\", protocol.name(), host.hostname, port, path)\n-                        } else {\n-                            format!(\"{}://{}{}\", protocol.name(), host.hostname, path)\n-                        }\n-                    },\n-                    (v, None) if v < HttpVersion::Http11 => {\n-                        // Attempt to use the local address? (host header is not required in HTTP/1.0).\n-                        match local_addr {\n-                            SocketAddr::V4(addr4) => format!(\"{}://{}:{}{}\", protocol.name(), addr4.ip(), local_addr.port(), path),\n-                            SocketAddr::V6(addr6) => format!(\"{}://[{}]:{}{}\", protocol.name(), addr6.ip(), local_addr.port(), path),\n-                        }\n-                    },\n-                    (_, None) => {\n-                        return Err(\"No host specified in request\".into())\n+    pub fn from_http(req: HttpRequest, local_addr: SocketAddr, protocol: &Protocol)\n+                     -> Result<Request, String> {\n+        let addr = req.remote_addr().cloned();\n+        let (method, uri, version, headers, body) = req.deconstruct();\n+        let url = {\n+            let path = uri.path();\n+            let url_string = match (version, headers.get::<headers::Host>()) {\n+                (_, Some(host)) => {\n+                    // Attempt to prepend the Host header (mandatory in HTTP/1.1)\n+                    if let Some(port) = host.port() {\n+                        format!(\"{}://{}:{}{}\", protocol.name(), host.hostname(), port, path)\n+                    } else {\n+                        format!(\"{}://{}{}\", protocol.name(), host.hostname(), path)\n                     }\n-                };\n-\n-                match Url::parse(&url_string) {\n-                    Ok(url) => url,\n-                    Err(e) => return Err(format!(\"Couldn't parse requested URL: {}\", e))\n+                },\n+                (v, None) if v < HttpVersion::Http11 => {\n+                    // Attempt to use the local address? (host header is not required in HTTP/1.0).\n+                    match local_addr {\n+                        SocketAddr::V4(addr4) => format!(\"{}://{}:{}{}\", protocol.name(), addr4.ip(), local_addr.port(), path),\n+                        SocketAddr::V6(addr6) => format!(\"{}://[{}]:{}{}\", protocol.name(), addr6.ip(), local_addr.port(), path),\n+                    }\n+                },\n+                (_, None) => {\n+                    return Err(\"No host specified in request\".into())\n                 }\n-            },\n-            _ => return Err(\"Unsupported request URI\".into())\n+            };\n+\n+            match Url::parse(&url_string) {\n+                Ok(url) => url,\n+                Err(e) => return Err(format!(\"Couldn't parse requested URL: {}\", e))\n+            }\n         };\n \n         Ok(Request {\n             url: url,\n             remote_addr: addr,\n             local_addr: local_addr,\n             headers: headers,\n-            body: Body::new(reader),\n+            body: Some(body),\n             method: method,\n             extensions: TypeMap::new(),\n             version: version,\n             _p: (),\n         })\n     }\n \n+    /// Get the contents of the body as a Vec<u8>\n+    ///\n+    /// This consumes the body future and turns it into Vec<u8>.  Note this should not be called\n+    /// from the main hyper thread, as it will potentially deadlock.\n+    pub fn get_body_contents(&mut self) -> Option<Vec<u8>> {","path":"src/request/mod.rs","position":158,"original_position":158,"commit_id":"3564b1cdc7bf2c5525b49d74ed9597fb59abb2a5","original_commit_id":"3564b1cdc7bf2c5525b49d74ed9597fb59abb2a5","user":{"login":"reem","id":4745181,"avatar_url":"https://avatars2.githubusercontent.com/u/4745181?v=3","gravatar_id":"","url":"https://api.github.com/users/reem","html_url":"https://github.com/reem","followers_url":"https://api.github.com/users/reem/followers","following_url":"https://api.github.com/users/reem/following{/other_user}","gists_url":"https://api.github.com/users/reem/gists{/gist_id}","starred_url":"https://api.github.com/users/reem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reem/subscriptions","organizations_url":"https://api.github.com/users/reem/orgs","repos_url":"https://api.github.com/users/reem/repos","events_url":"https://api.github.com/users/reem/events{/privacy}","received_events_url":"https://api.github.com/users/reem/received_events","type":"User","site_admin":false},"body":"That sounds great. I don't love the name, but I can't really think of anything better right now. `get_body` is easy to confuse with `.body`, and anything else is as long. Does anyone else have ideas? I'll keep thinking about it.\r\n\r\nThere is one further issue with this API: it encourages reading an unlimited amount of data over the network, which is basically never what you want to do. The body-parser crate gets around this by having a [default maximum length](https://github.com/iron/body-parser/blob/master/src/lib.rs#L63) and [accepting further configuration](https://github.com/iron/body-parser/blob/master/src/lib.rs#L49) via `extensions`. We could do that here instead, but the API is getting a little complex to go in core.","created_at":"2017-03-25T07:38:57Z","updated_at":"2017-03-25T07:38:57Z","html_url":"https://github.com/iron/iron/pull/523#discussion_r108030601","pull_request_url":"https://api.github.com/repos/iron/iron/pulls/523","_links":{"self":{"href":"https://api.github.com/repos/iron/iron/pulls/comments/108030601"},"html":{"href":"https://github.com/iron/iron/pull/523#discussion_r108030601"},"pull_request":{"href":"https://api.github.com/repos/iron/iron/pulls/523"}}},"pull_request":{"url":"https://api.github.com/repos/iron/iron/pulls/523","id":106918157,"html_url":"https://github.com/iron/iron/pull/523","diff_url":"https://github.com/iron/iron/pull/523.diff","patch_url":"https://github.com/iron/iron/pull/523.patch","issue_url":"https://api.github.com/repos/iron/iron/issues/523","number":523,"state":"open","locked":false,"title":"Async Iron with Hyper tokio using a cpupool.","user":{"login":"MJDSys","id":2875429,"avatar_url":"https://avatars1.githubusercontent.com/u/2875429?v=3","gravatar_id":"","url":"https://api.github.com/users/MJDSys","html_url":"https://github.com/MJDSys","followers_url":"https://api.github.com/users/MJDSys/followers","following_url":"https://api.github.com/users/MJDSys/following{/other_user}","gists_url":"https://api.github.com/users/MJDSys/gists{/gist_id}","starred_url":"https://api.github.com/users/MJDSys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MJDSys/subscriptions","organizations_url":"https://api.github.com/users/MJDSys/orgs","repos_url":"https://api.github.com/users/MJDSys/repos","events_url":"https://api.github.com/users/MJDSys/events{/privacy}","received_events_url":"https://api.github.com/users/MJDSys/received_events","type":"User","site_admin":false},"body":"This PR is the start of me working on porting Iron over to async Hyper/tokio (issue #501).  This RFC start just moves everything to compile on the new branch.\r\n\r\nI don't know if you want to accept this PR (after whatever cleanup is necessary!) as a base so someone (maybe me if my time stays available) can start working on a proper async story for Iron.  If you prefer this PR develops into the full async support, that's fine too I'll just leave it open as I continue developing.","created_at":"2017-02-19T21:49:39Z","updated_at":"2017-03-25T07:38:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c5ccddbc89f3b5f4d18f2558600aa82ffa3d0819","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/iron/iron/pulls/523/commits","review_comments_url":"https://api.github.com/repos/iron/iron/pulls/523/comments","review_comment_url":"https://api.github.com/repos/iron/iron/pulls/comments{/number}","comments_url":"https://api.github.com/repos/iron/iron/issues/523/comments","statuses_url":"https://api.github.com/repos/iron/iron/statuses/3564b1cdc7bf2c5525b49d74ed9597fb59abb2a5","head":{"label":"MJDSys:async","ref":"async","sha":"3564b1cdc7bf2c5525b49d74ed9597fb59abb2a5","user":{"login":"MJDSys","id":2875429,"avatar_url":"https://avatars1.githubusercontent.com/u/2875429?v=3","gravatar_id":"","url":"https://api.github.com/users/MJDSys","html_url":"https://github.com/MJDSys","followers_url":"https://api.github.com/users/MJDSys/followers","following_url":"https://api.github.com/users/MJDSys/following{/other_user}","gists_url":"https://api.github.com/users/MJDSys/gists{/gist_id}","starred_url":"https://api.github.com/users/MJDSys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MJDSys/subscriptions","organizations_url":"https://api.github.com/users/MJDSys/orgs","repos_url":"https://api.github.com/users/MJDSys/repos","events_url":"https://api.github.com/users/MJDSys/events{/privacy}","received_events_url":"https://api.github.com/users/MJDSys/received_events","type":"User","site_admin":false},"repo":{"id":81409520,"name":"iron","full_name":"MJDSys/iron","owner":{"login":"MJDSys","id":2875429,"avatar_url":"https://avatars1.githubusercontent.com/u/2875429?v=3","gravatar_id":"","url":"https://api.github.com/users/MJDSys","html_url":"https://github.com/MJDSys","followers_url":"https://api.github.com/users/MJDSys/followers","following_url":"https://api.github.com/users/MJDSys/following{/other_user}","gists_url":"https://api.github.com/users/MJDSys/gists{/gist_id}","starred_url":"https://api.github.com/users/MJDSys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MJDSys/subscriptions","organizations_url":"https://api.github.com/users/MJDSys/orgs","repos_url":"https://api.github.com/users/MJDSys/repos","events_url":"https://api.github.com/users/MJDSys/events{/privacy}","received_events_url":"https://api.github.com/users/MJDSys/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MJDSys/iron","description":"An Extensible, Concurrent Web Framework for Rust","fork":true,"url":"https://api.github.com/repos/MJDSys/iron","forks_url":"https://api.github.com/repos/MJDSys/iron/forks","keys_url":"https://api.github.com/repos/MJDSys/iron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MJDSys/iron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MJDSys/iron/teams","hooks_url":"https://api.github.com/repos/MJDSys/iron/hooks","issue_events_url":"https://api.github.com/repos/MJDSys/iron/issues/events{/number}","events_url":"https://api.github.com/repos/MJDSys/iron/events","assignees_url":"https://api.github.com/repos/MJDSys/iron/assignees{/user}","branches_url":"https://api.github.com/repos/MJDSys/iron/branches{/branch}","tags_url":"https://api.github.com/repos/MJDSys/iron/tags","blobs_url":"https://api.github.com/repos/MJDSys/iron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MJDSys/iron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MJDSys/iron/git/refs{/sha}","trees_url":"https://api.github.com/repos/MJDSys/iron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MJDSys/iron/statuses/{sha}","languages_url":"https://api.github.com/repos/MJDSys/iron/languages","stargazers_url":"https://api.github.com/repos/MJDSys/iron/stargazers","contributors_url":"https://api.github.com/repos/MJDSys/iron/contributors","subscribers_url":"https://api.github.com/repos/MJDSys/iron/subscribers","subscription_url":"https://api.github.com/repos/MJDSys/iron/subscription","commits_url":"https://api.github.com/repos/MJDSys/iron/commits{/sha}","git_commits_url":"https://api.github.com/repos/MJDSys/iron/git/commits{/sha}","comments_url":"https://api.github.com/repos/MJDSys/iron/comments{/number}","issue_comment_url":"https://api.github.com/repos/MJDSys/iron/issues/comments{/number}","contents_url":"https://api.github.com/repos/MJDSys/iron/contents/{+path}","compare_url":"https://api.github.com/repos/MJDSys/iron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MJDSys/iron/merges","archive_url":"https://api.github.com/repos/MJDSys/iron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MJDSys/iron/downloads","issues_url":"https://api.github.com/repos/MJDSys/iron/issues{/number}","pulls_url":"https://api.github.com/repos/MJDSys/iron/pulls{/number}","milestones_url":"https://api.github.com/repos/MJDSys/iron/milestones{/number}","notifications_url":"https://api.github.com/repos/MJDSys/iron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MJDSys/iron/labels{/name}","releases_url":"https://api.github.com/repos/MJDSys/iron/releases{/id}","deployments_url":"https://api.github.com/repos/MJDSys/iron/deployments","created_at":"2017-02-09T04:36:28Z","updated_at":"2017-02-09T04:36:29Z","pushed_at":"2017-03-21T05:27:41Z","git_url":"git://github.com/MJDSys/iron.git","ssh_url":"git@github.com:MJDSys/iron.git","clone_url":"https://github.com/MJDSys/iron.git","svn_url":"https://github.com/MJDSys/iron","homepage":"http://ironframework.io","size":543,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"iron:master","ref":"master","sha":"21c7dae29c3c214c08533c2a55ac649b418f2fe3","user":{"login":"iron","id":7853871,"avatar_url":"https://avatars0.githubusercontent.com/u/7853871?v=3","gravatar_id":"","url":"https://api.github.com/users/iron","html_url":"https://github.com/iron","followers_url":"https://api.github.com/users/iron/followers","following_url":"https://api.github.com/users/iron/following{/other_user}","gists_url":"https://api.github.com/users/iron/gists{/gist_id}","starred_url":"https://api.github.com/users/iron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iron/subscriptions","organizations_url":"https://api.github.com/users/iron/orgs","repos_url":"https://api.github.com/users/iron/repos","events_url":"https://api.github.com/users/iron/events{/privacy}","received_events_url":"https://api.github.com/users/iron/received_events","type":"Organization","site_admin":false},"repo":{"id":20702627,"name":"iron","full_name":"iron/iron","owner":{"login":"iron","id":7853871,"avatar_url":"https://avatars0.githubusercontent.com/u/7853871?v=3","gravatar_id":"","url":"https://api.github.com/users/iron","html_url":"https://github.com/iron","followers_url":"https://api.github.com/users/iron/followers","following_url":"https://api.github.com/users/iron/following{/other_user}","gists_url":"https://api.github.com/users/iron/gists{/gist_id}","starred_url":"https://api.github.com/users/iron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iron/subscriptions","organizations_url":"https://api.github.com/users/iron/orgs","repos_url":"https://api.github.com/users/iron/repos","events_url":"https://api.github.com/users/iron/events{/privacy}","received_events_url":"https://api.github.com/users/iron/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/iron/iron","description":"An Extensible, Concurrent Web Framework for Rust","fork":false,"url":"https://api.github.com/repos/iron/iron","forks_url":"https://api.github.com/repos/iron/iron/forks","keys_url":"https://api.github.com/repos/iron/iron/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iron/iron/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iron/iron/teams","hooks_url":"https://api.github.com/repos/iron/iron/hooks","issue_events_url":"https://api.github.com/repos/iron/iron/issues/events{/number}","events_url":"https://api.github.com/repos/iron/iron/events","assignees_url":"https://api.github.com/repos/iron/iron/assignees{/user}","branches_url":"https://api.github.com/repos/iron/iron/branches{/branch}","tags_url":"https://api.github.com/repos/iron/iron/tags","blobs_url":"https://api.github.com/repos/iron/iron/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iron/iron/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iron/iron/git/refs{/sha}","trees_url":"https://api.github.com/repos/iron/iron/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iron/iron/statuses/{sha}","languages_url":"https://api.github.com/repos/iron/iron/languages","stargazers_url":"https://api.github.com/repos/iron/iron/stargazers","contributors_url":"https://api.github.com/repos/iron/iron/contributors","subscribers_url":"https://api.github.com/repos/iron/iron/subscribers","subscription_url":"https://api.github.com/repos/iron/iron/subscription","commits_url":"https://api.github.com/repos/iron/iron/commits{/sha}","git_commits_url":"https://api.github.com/repos/iron/iron/git/commits{/sha}","comments_url":"https://api.github.com/repos/iron/iron/comments{/number}","issue_comment_url":"https://api.github.com/repos/iron/iron/issues/comments{/number}","contents_url":"https://api.github.com/repos/iron/iron/contents/{+path}","compare_url":"https://api.github.com/repos/iron/iron/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iron/iron/merges","archive_url":"https://api.github.com/repos/iron/iron/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iron/iron/downloads","issues_url":"https://api.github.com/repos/iron/iron/issues{/number}","pulls_url":"https://api.github.com/repos/iron/iron/pulls{/number}","milestones_url":"https://api.github.com/repos/iron/iron/milestones{/number}","notifications_url":"https://api.github.com/repos/iron/iron/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iron/iron/labels{/name}","releases_url":"https://api.github.com/repos/iron/iron/releases{/id}","deployments_url":"https://api.github.com/repos/iron/iron/deployments","created_at":"2014-06-10T21:37:29Z","updated_at":"2017-03-25T01:29:49Z","pushed_at":"2017-03-21T05:27:42Z","git_url":"git://github.com/iron/iron.git","ssh_url":"git@github.com:iron/iron.git","clone_url":"https://github.com/iron/iron.git","svn_url":"https://github.com/iron/iron","homepage":"http://ironframework.io","size":525,"stargazers_count":3890,"watchers_count":3890,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":282,"mirror_url":null,"open_issues_count":42,"forks":282,"open_issues":42,"watchers":3890,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/iron/iron/pulls/523"},"html":{"href":"https://github.com/iron/iron/pull/523"},"issue":{"href":"https://api.github.com/repos/iron/iron/issues/523"},"comments":{"href":"https://api.github.com/repos/iron/iron/issues/523/comments"},"review_comments":{"href":"https://api.github.com/repos/iron/iron/pulls/523/comments"},"review_comment":{"href":"https://api.github.com/repos/iron/iron/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/iron/iron/pulls/523/commits"},"statuses":{"href":"https://api.github.com/repos/iron/iron/statuses/3564b1cdc7bf2c5525b49d74ed9597fb59abb2a5"}}}}
{"actor":{"display_login":"reem"}}