{"action":"created","comment":{"url":"https://api.github.com/repos/hyperium/hyper/pulls/comments/75943365","id":75943365,"diff_hunk":"@@ -66,17 +68,31 @@ impl<'a, T> Request<'a, T> {\n     #[inline]\n     pub fn version(&self) -> &HttpVersion { &self.version }\n \n-    /*\n     /// The target path of this Request.\n     #[inline]\n-    pub fn path(&self) -> Option<&str> {\n-        match *self.uri {\n-            RequestUri::AbsolutePath(ref s) => Some(s),\n-            RequestUri::AbsoluteUri(ref url) => Some(&url[::url::Position::BeforePath..]),\n-            _ => None\n+    pub fn path(&self) -> Option<Cow<str>> {\n+        match self.uri {\n+            RequestUri::AbsolutePath(ref s) => {\n+                let url = Url::parse(\"http://example.com\").ok().and_then(|u| u.join(s).ok());","path":"src/server/request.rs","position":31,"original_position":31,"commit_id":"e4ec7e0644b36b81407ec1899036c5c63b1dc2b9","original_commit_id":"e4ec7e0644b36b81407ec1899036c5c63b1dc2b9","user":{"login":"seanmonstar","id":51479,"avatar_url":"https://avatars.githubusercontent.com/u/51479?v=3","gravatar_id":"","url":"https://api.github.com/users/seanmonstar","html_url":"https://github.com/seanmonstar","followers_url":"https://api.github.com/users/seanmonstar/followers","following_url":"https://api.github.com/users/seanmonstar/following{/other_user}","gists_url":"https://api.github.com/users/seanmonstar/gists{/gist_id}","starred_url":"https://api.github.com/users/seanmonstar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanmonstar/subscriptions","organizations_url":"https://api.github.com/users/seanmonstar/orgs","repos_url":"https://api.github.com/users/seanmonstar/repos","events_url":"https://api.github.com/users/seanmonstar/events{/privacy}","received_events_url":"https://api.github.com/users/seanmonstar/received_events","type":"User","site_admin":false},"body":"Oh ok, good call. I'm wondering whether it's better to run the Url parser\nwhen constructing the RequestUri, and thus be able to return a reference,\nor do it on demand, as this patch does.\n\nOn Tue, Aug 23, 2016, 7:30 AM Ahmed Charles <notifications@github.com>\nwrote:\n\n> In src/server/request.rs\n> <https://github.com/hyperium/hyper/pull/899#discussion_r75877722>:\n>\n> >      /// The target path of this Request.\n> >      #[inline]\n> > -    pub fn path(&self) -> Option<&str> {\n> > -        match *self.uri {\n> > -            RequestUri::AbsolutePath(ref s) => Some(s),\n> > -            RequestUri::AbsoluteUri(ref url) => Some(&url[::url::Position::BeforePath..]),\n> > -            _ => None\n> > +    pub fn path(&self) -> Option<Cow<str>> {\n> > +        match self.uri {\n> > +            RequestUri::AbsolutePath(ref s) => {\n> > +                let url = Url::parse(\"http://example.com\").ok().and_then(|u| u.join(s).ok());\n>\n> I was going for consistency and doing it in a way that I don't have to\n> read the RFC and implement correct parsing and interpretation of urls.\n> Url::parse normalizes the urls, and therefore, it makes a copy. It would be\n> weird if normalized paths and queries were returned for AbsoluteUri but not\n> for AbsolutePath.\n>\n> —\n> You are receiving this because you commented.\n>\n>\n> Reply to this email directly, view it on GitHub\n> <https://github.com/hyperium/hyper/pull/899/files/e4ec7e0644b36b81407ec1899036c5c63b1dc2b9#r75877722>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AADJF2Xxk2msmuotBxxEluLzk2527Onvks5qiwQMgaJpZM4JqgGd>\n> .\n>\n","created_at":"2016-08-23T20:23:08Z","updated_at":"2016-08-23T20:23:08Z","html_url":"https://github.com/hyperium/hyper/pull/899#discussion_r75943365","pull_request_url":"https://api.github.com/repos/hyperium/hyper/pulls/899","_links":{"self":{"href":"https://api.github.com/repos/hyperium/hyper/pulls/comments/75943365"},"html":{"href":"https://github.com/hyperium/hyper/pull/899#discussion_r75943365"},"pull_request":{"href":"https://api.github.com/repos/hyperium/hyper/pulls/899"}}},"pull_request":{"url":"https://api.github.com/repos/hyperium/hyper/pulls/899","id":82295564,"html_url":"https://github.com/hyperium/hyper/pull/899","diff_url":"https://github.com/hyperium/hyper/pull/899.diff","patch_url":"https://github.com/hyperium/hyper/pull/899.patch","issue_url":"https://api.github.com/repos/hyperium/hyper/issues/899","number":899,"state":"open","locked":false,"title":"feat(server): add path() and query() to Request","user":{"login":"ahmedcharles","id":3112514,"avatar_url":"https://avatars.githubusercontent.com/u/3112514?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmedcharles","html_url":"https://github.com/ahmedcharles","followers_url":"https://api.github.com/users/ahmedcharles/followers","following_url":"https://api.github.com/users/ahmedcharles/following{/other_user}","gists_url":"https://api.github.com/users/ahmedcharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmedcharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmedcharles/subscriptions","organizations_url":"https://api.github.com/users/ahmedcharles/orgs","repos_url":"https://api.github.com/users/ahmedcharles/repos","events_url":"https://api.github.com/users/ahmedcharles/events{/privacy}","received_events_url":"https://api.github.com/users/ahmedcharles/received_events","type":"User","site_admin":false},"body":"Fixes #896 and #897.\r\n\r\nAlso improve RequestUri tests.","created_at":"2016-08-23T02:47:00Z","updated_at":"2016-08-23T20:23:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53c8ea32dcf95039ce5021e6993fd01817ccce2e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hyperium/hyper/pulls/899/commits","review_comments_url":"https://api.github.com/repos/hyperium/hyper/pulls/899/comments","review_comment_url":"https://api.github.com/repos/hyperium/hyper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hyperium/hyper/issues/899/comments","statuses_url":"https://api.github.com/repos/hyperium/hyper/statuses/e4ec7e0644b36b81407ec1899036c5c63b1dc2b9","head":{"label":"ahmedcharles:request","ref":"request","sha":"e4ec7e0644b36b81407ec1899036c5c63b1dc2b9","user":{"login":"ahmedcharles","id":3112514,"avatar_url":"https://avatars.githubusercontent.com/u/3112514?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmedcharles","html_url":"https://github.com/ahmedcharles","followers_url":"https://api.github.com/users/ahmedcharles/followers","following_url":"https://api.github.com/users/ahmedcharles/following{/other_user}","gists_url":"https://api.github.com/users/ahmedcharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmedcharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmedcharles/subscriptions","organizations_url":"https://api.github.com/users/ahmedcharles/orgs","repos_url":"https://api.github.com/users/ahmedcharles/repos","events_url":"https://api.github.com/users/ahmedcharles/events{/privacy}","received_events_url":"https://api.github.com/users/ahmedcharles/received_events","type":"User","site_admin":false},"repo":{"id":66327045,"name":"hyper","full_name":"ahmedcharles/hyper","owner":{"login":"ahmedcharles","id":3112514,"avatar_url":"https://avatars.githubusercontent.com/u/3112514?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmedcharles","html_url":"https://github.com/ahmedcharles","followers_url":"https://api.github.com/users/ahmedcharles/followers","following_url":"https://api.github.com/users/ahmedcharles/following{/other_user}","gists_url":"https://api.github.com/users/ahmedcharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmedcharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmedcharles/subscriptions","organizations_url":"https://api.github.com/users/ahmedcharles/orgs","repos_url":"https://api.github.com/users/ahmedcharles/repos","events_url":"https://api.github.com/users/ahmedcharles/events{/privacy}","received_events_url":"https://api.github.com/users/ahmedcharles/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ahmedcharles/hyper","description":"An HTTP library for Rust","fork":true,"url":"https://api.github.com/repos/ahmedcharles/hyper","forks_url":"https://api.github.com/repos/ahmedcharles/hyper/forks","keys_url":"https://api.github.com/repos/ahmedcharles/hyper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ahmedcharles/hyper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ahmedcharles/hyper/teams","hooks_url":"https://api.github.com/repos/ahmedcharles/hyper/hooks","issue_events_url":"https://api.github.com/repos/ahmedcharles/hyper/issues/events{/number}","events_url":"https://api.github.com/repos/ahmedcharles/hyper/events","assignees_url":"https://api.github.com/repos/ahmedcharles/hyper/assignees{/user}","branches_url":"https://api.github.com/repos/ahmedcharles/hyper/branches{/branch}","tags_url":"https://api.github.com/repos/ahmedcharles/hyper/tags","blobs_url":"https://api.github.com/repos/ahmedcharles/hyper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ahmedcharles/hyper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ahmedcharles/hyper/git/refs{/sha}","trees_url":"https://api.github.com/repos/ahmedcharles/hyper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ahmedcharles/hyper/statuses/{sha}","languages_url":"https://api.github.com/repos/ahmedcharles/hyper/languages","stargazers_url":"https://api.github.com/repos/ahmedcharles/hyper/stargazers","contributors_url":"https://api.github.com/repos/ahmedcharles/hyper/contributors","subscribers_url":"https://api.github.com/repos/ahmedcharles/hyper/subscribers","subscription_url":"https://api.github.com/repos/ahmedcharles/hyper/subscription","commits_url":"https://api.github.com/repos/ahmedcharles/hyper/commits{/sha}","git_commits_url":"https://api.github.com/repos/ahmedcharles/hyper/git/commits{/sha}","comments_url":"https://api.github.com/repos/ahmedcharles/hyper/comments{/number}","issue_comment_url":"https://api.github.com/repos/ahmedcharles/hyper/issues/comments{/number}","contents_url":"https://api.github.com/repos/ahmedcharles/hyper/contents/{+path}","compare_url":"https://api.github.com/repos/ahmedcharles/hyper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ahmedcharles/hyper/merges","archive_url":"https://api.github.com/repos/ahmedcharles/hyper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ahmedcharles/hyper/downloads","issues_url":"https://api.github.com/repos/ahmedcharles/hyper/issues{/number}","pulls_url":"https://api.github.com/repos/ahmedcharles/hyper/pulls{/number}","milestones_url":"https://api.github.com/repos/ahmedcharles/hyper/milestones{/number}","notifications_url":"https://api.github.com/repos/ahmedcharles/hyper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ahmedcharles/hyper/labels{/name}","releases_url":"https://api.github.com/repos/ahmedcharles/hyper/releases{/id}","deployments_url":"https://api.github.com/repos/ahmedcharles/hyper/deployments","created_at":"2016-08-23T02:45:18Z","updated_at":"2016-08-23T02:45:20Z","pushed_at":"2016-08-23T02:46:29Z","git_url":"git://github.com/ahmedcharles/hyper.git","ssh_url":"git@github.com:ahmedcharles/hyper.git","clone_url":"https://github.com/ahmedcharles/hyper.git","svn_url":"https://github.com/ahmedcharles/hyper","homepage":"http://hyper.rs","size":8104,"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":"hyperium:master","ref":"master","sha":"74136de9609e9e272e3fc2de1b6b939e629df093","user":{"login":"hyperium","id":8730506,"avatar_url":"https://avatars.githubusercontent.com/u/8730506?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperium","html_url":"https://github.com/hyperium","followers_url":"https://api.github.com/users/hyperium/followers","following_url":"https://api.github.com/users/hyperium/following{/other_user}","gists_url":"https://api.github.com/users/hyperium/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperium/subscriptions","organizations_url":"https://api.github.com/users/hyperium/orgs","repos_url":"https://api.github.com/users/hyperium/repos","events_url":"https://api.github.com/users/hyperium/events{/privacy}","received_events_url":"https://api.github.com/users/hyperium/received_events","type":"Organization","site_admin":false},"repo":{"id":23500865,"name":"hyper","full_name":"hyperium/hyper","owner":{"login":"hyperium","id":8730506,"avatar_url":"https://avatars.githubusercontent.com/u/8730506?v=3","gravatar_id":"","url":"https://api.github.com/users/hyperium","html_url":"https://github.com/hyperium","followers_url":"https://api.github.com/users/hyperium/followers","following_url":"https://api.github.com/users/hyperium/following{/other_user}","gists_url":"https://api.github.com/users/hyperium/gists{/gist_id}","starred_url":"https://api.github.com/users/hyperium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hyperium/subscriptions","organizations_url":"https://api.github.com/users/hyperium/orgs","repos_url":"https://api.github.com/users/hyperium/repos","events_url":"https://api.github.com/users/hyperium/events{/privacy}","received_events_url":"https://api.github.com/users/hyperium/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hyperium/hyper","description":"An HTTP library for Rust","fork":false,"url":"https://api.github.com/repos/hyperium/hyper","forks_url":"https://api.github.com/repos/hyperium/hyper/forks","keys_url":"https://api.github.com/repos/hyperium/hyper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hyperium/hyper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hyperium/hyper/teams","hooks_url":"https://api.github.com/repos/hyperium/hyper/hooks","issue_events_url":"https://api.github.com/repos/hyperium/hyper/issues/events{/number}","events_url":"https://api.github.com/repos/hyperium/hyper/events","assignees_url":"https://api.github.com/repos/hyperium/hyper/assignees{/user}","branches_url":"https://api.github.com/repos/hyperium/hyper/branches{/branch}","tags_url":"https://api.github.com/repos/hyperium/hyper/tags","blobs_url":"https://api.github.com/repos/hyperium/hyper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hyperium/hyper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hyperium/hyper/git/refs{/sha}","trees_url":"https://api.github.com/repos/hyperium/hyper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hyperium/hyper/statuses/{sha}","languages_url":"https://api.github.com/repos/hyperium/hyper/languages","stargazers_url":"https://api.github.com/repos/hyperium/hyper/stargazers","contributors_url":"https://api.github.com/repos/hyperium/hyper/contributors","subscribers_url":"https://api.github.com/repos/hyperium/hyper/subscribers","subscription_url":"https://api.github.com/repos/hyperium/hyper/subscription","commits_url":"https://api.github.com/repos/hyperium/hyper/commits{/sha}","git_commits_url":"https://api.github.com/repos/hyperium/hyper/git/commits{/sha}","comments_url":"https://api.github.com/repos/hyperium/hyper/comments{/number}","issue_comment_url":"https://api.github.com/repos/hyperium/hyper/issues/comments{/number}","contents_url":"https://api.github.com/repos/hyperium/hyper/contents/{+path}","compare_url":"https://api.github.com/repos/hyperium/hyper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hyperium/hyper/merges","archive_url":"https://api.github.com/repos/hyperium/hyper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hyperium/hyper/downloads","issues_url":"https://api.github.com/repos/hyperium/hyper/issues{/number}","pulls_url":"https://api.github.com/repos/hyperium/hyper/pulls{/number}","milestones_url":"https://api.github.com/repos/hyperium/hyper/milestones{/number}","notifications_url":"https://api.github.com/repos/hyperium/hyper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hyperium/hyper/labels{/name}","releases_url":"https://api.github.com/repos/hyperium/hyper/releases{/id}","deployments_url":"https://api.github.com/repos/hyperium/hyper/deployments","created_at":"2014-08-30T21:14:33Z","updated_at":"2016-08-22T09:57:40Z","pushed_at":"2016-08-23T19:17:38Z","git_url":"git://github.com/hyperium/hyper.git","ssh_url":"git@github.com:hyperium/hyper.git","clone_url":"https://github.com/hyperium/hyper.git","svn_url":"https://github.com/hyperium/hyper","homepage":"http://hyper.rs","size":11120,"stargazers_count":1893,"watchers_count":1893,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":320,"mirror_url":null,"open_issues_count":36,"forks":320,"open_issues":36,"watchers":1893,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hyperium/hyper/pulls/899"},"html":{"href":"https://github.com/hyperium/hyper/pull/899"},"issue":{"href":"https://api.github.com/repos/hyperium/hyper/issues/899"},"comments":{"href":"https://api.github.com/repos/hyperium/hyper/issues/899/comments"},"review_comments":{"href":"https://api.github.com/repos/hyperium/hyper/pulls/899/comments"},"review_comment":{"href":"https://api.github.com/repos/hyperium/hyper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hyperium/hyper/pulls/899/commits"},"statuses":{"href":"https://api.github.com/repos/hyperium/hyper/statuses/e4ec7e0644b36b81407ec1899036c5c63b1dc2b9"}}}}
{"actor":{"display_login":"seanmonstar"}}