{"action":"created","comment":{"url":"https://api.github.com/repos/nette/http/pulls/comments/51481911","id":51481911,"diff_hunk":"@@ -60,25 +60,57 @@ public function setProxy($proxy)\n \t */\n \tpublic function createHttpRequest()\n \t{\n+\t\t$remoteAddr = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : NULL;\n+\t\t$remoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : NULL;\n+\n+\t\t// use real client address and host if trusted proxy is used\n+\t\t$usingTrustedProxy = FALSE;\n+\t\tforeach ($this->proxies as $proxy) {\n+\t\t\tif (Helpers::ipMatch($remoteAddr, $proxy)) {\n+\t\t\t\t$usingTrustedProxy = TRUE;\n+\n+\t\t\t\tif (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {\n+\t\t\t\t\t$remoteAddr = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_FOR'])));\n+\t\t\t\t}\n+\t\t\t\tif (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {\n+\t\t\t\t\t$remoteHost = trim(current(explode(',', $_SERVER['HTTP_X_FORWARDED_HOST'])));\n+\t\t\t\t}","path":"src/Http/RequestFactory.php","position":18,"original_position":18,"commit_id":"efb2c32c674117b4c1d1917ec00fc312ad9d6d99","original_commit_id":"efb2c32c674117b4c1d1917ec00fc312ad9d6d99","user":{"login":"grongor","id":972493,"avatar_url":"https://avatars.githubusercontent.com/u/972493?v=3","gravatar_id":"","url":"https://api.github.com/users/grongor","html_url":"https://github.com/grongor","followers_url":"https://api.github.com/users/grongor/followers","following_url":"https://api.github.com/users/grongor/following{/other_user}","gists_url":"https://api.github.com/users/grongor/gists{/gist_id}","starred_url":"https://api.github.com/users/grongor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grongor/subscriptions","organizations_url":"https://api.github.com/users/grongor/orgs","repos_url":"https://api.github.com/users/grongor/repos","events_url":"https://api.github.com/users/grongor/events{/privacy}","received_events_url":"https://api.github.com/users/grongor/received_events","type":"User","site_admin":false},"body":"Well, I can do that but I will have to copy the `$usingTrustedProxy === true` condition ... do you think that removing one indention is worth it?","created_at":"2016-02-01T21:17:12Z","updated_at":"2016-02-01T21:17:12Z","html_url":"https://github.com/nette/http/pull/81#discussion_r51481911","pull_request_url":"https://api.github.com/repos/nette/http/pulls/81","_links":{"self":{"href":"https://api.github.com/repos/nette/http/pulls/comments/51481911"},"html":{"href":"https://github.com/nette/http/pull/81#discussion_r51481911"},"pull_request":{"href":"https://api.github.com/repos/nette/http/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/nette/http/pulls/81","id":57780203,"html_url":"https://github.com/nette/http/pull/81","diff_url":"https://github.com/nette/http/pull/81.diff","patch_url":"https://github.com/nette/http/pull/81.patch","issue_url":"https://api.github.com/repos/nette/http/issues/81","number":81,"state":"open","locked":false,"title":"RequestFactory: fix behavior behind proxy","user":{"login":"grongor","id":972493,"avatar_url":"https://avatars.githubusercontent.com/u/972493?v=3","gravatar_id":"","url":"https://api.github.com/users/grongor","html_url":"https://github.com/grongor","followers_url":"https://api.github.com/users/grongor/followers","following_url":"https://api.github.com/users/grongor/following{/other_user}","gists_url":"https://api.github.com/users/grongor/gists{/gist_id}","starred_url":"https://api.github.com/users/grongor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grongor/subscriptions","organizations_url":"https://api.github.com/users/grongor/orgs","repos_url":"https://api.github.com/users/grongor/repos","events_url":"https://api.github.com/users/grongor/events{/privacy}","received_events_url":"https://api.github.com/users/grongor/received_events","type":"User","site_admin":false},"body":"- bugfix\r\n- issues - #4 \r\n- documentation - not needed\r\n- BC break - may break some edge-case server proxies, most servers should stay intact","created_at":"2016-01-31T21:06:22Z","updated_at":"2016-02-01T21:17:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bda139211e4f6a704115ac256c929f8d41a77b02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nette/http/pulls/81/commits","review_comments_url":"https://api.github.com/repos/nette/http/pulls/81/comments","review_comment_url":"https://api.github.com/repos/nette/http/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nette/http/issues/81/comments","statuses_url":"https://api.github.com/repos/nette/http/statuses/efb2c32c674117b4c1d1917ec00fc312ad9d6d99","head":{"label":"grongor:fix-proxy-https","ref":"fix-proxy-https","sha":"efb2c32c674117b4c1d1917ec00fc312ad9d6d99","user":{"login":"grongor","id":972493,"avatar_url":"https://avatars.githubusercontent.com/u/972493?v=3","gravatar_id":"","url":"https://api.github.com/users/grongor","html_url":"https://github.com/grongor","followers_url":"https://api.github.com/users/grongor/followers","following_url":"https://api.github.com/users/grongor/following{/other_user}","gists_url":"https://api.github.com/users/grongor/gists{/gist_id}","starred_url":"https://api.github.com/users/grongor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grongor/subscriptions","organizations_url":"https://api.github.com/users/grongor/orgs","repos_url":"https://api.github.com/users/grongor/repos","events_url":"https://api.github.com/users/grongor/events{/privacy}","received_events_url":"https://api.github.com/users/grongor/received_events","type":"User","site_admin":false},"repo":{"id":50788130,"name":"http","full_name":"grongor/http","owner":{"login":"grongor","id":972493,"avatar_url":"https://avatars.githubusercontent.com/u/972493?v=3","gravatar_id":"","url":"https://api.github.com/users/grongor","html_url":"https://github.com/grongor","followers_url":"https://api.github.com/users/grongor/followers","following_url":"https://api.github.com/users/grongor/following{/other_user}","gists_url":"https://api.github.com/users/grongor/gists{/gist_id}","starred_url":"https://api.github.com/users/grongor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grongor/subscriptions","organizations_url":"https://api.github.com/users/grongor/orgs","repos_url":"https://api.github.com/users/grongor/repos","events_url":"https://api.github.com/users/grongor/events{/privacy}","received_events_url":"https://api.github.com/users/grongor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grongor/http","description":"Nette HTTP: layer for the HTTP request & response","fork":true,"url":"https://api.github.com/repos/grongor/http","forks_url":"https://api.github.com/repos/grongor/http/forks","keys_url":"https://api.github.com/repos/grongor/http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grongor/http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grongor/http/teams","hooks_url":"https://api.github.com/repos/grongor/http/hooks","issue_events_url":"https://api.github.com/repos/grongor/http/issues/events{/number}","events_url":"https://api.github.com/repos/grongor/http/events","assignees_url":"https://api.github.com/repos/grongor/http/assignees{/user}","branches_url":"https://api.github.com/repos/grongor/http/branches{/branch}","tags_url":"https://api.github.com/repos/grongor/http/tags","blobs_url":"https://api.github.com/repos/grongor/http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grongor/http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grongor/http/git/refs{/sha}","trees_url":"https://api.github.com/repos/grongor/http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grongor/http/statuses/{sha}","languages_url":"https://api.github.com/repos/grongor/http/languages","stargazers_url":"https://api.github.com/repos/grongor/http/stargazers","contributors_url":"https://api.github.com/repos/grongor/http/contributors","subscribers_url":"https://api.github.com/repos/grongor/http/subscribers","subscription_url":"https://api.github.com/repos/grongor/http/subscription","commits_url":"https://api.github.com/repos/grongor/http/commits{/sha}","git_commits_url":"https://api.github.com/repos/grongor/http/git/commits{/sha}","comments_url":"https://api.github.com/repos/grongor/http/comments{/number}","issue_comment_url":"https://api.github.com/repos/grongor/http/issues/comments{/number}","contents_url":"https://api.github.com/repos/grongor/http/contents/{+path}","compare_url":"https://api.github.com/repos/grongor/http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grongor/http/merges","archive_url":"https://api.github.com/repos/grongor/http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grongor/http/downloads","issues_url":"https://api.github.com/repos/grongor/http/issues{/number}","pulls_url":"https://api.github.com/repos/grongor/http/pulls{/number}","milestones_url":"https://api.github.com/repos/grongor/http/milestones{/number}","notifications_url":"https://api.github.com/repos/grongor/http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grongor/http/labels{/name}","releases_url":"https://api.github.com/repos/grongor/http/releases{/id}","deployments_url":"https://api.github.com/repos/grongor/http/deployments","created_at":"2016-01-31T18:19:26Z","updated_at":"2016-01-31T18:19:27Z","pushed_at":"2016-02-01T21:04:11Z","git_url":"git://github.com/grongor/http.git","ssh_url":"git@github.com:grongor/http.git","clone_url":"https://github.com/grongor/http.git","svn_url":"https://github.com/grongor/http","homepage":"https://nette.org","size":611,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"nette:master","ref":"master","sha":"8fff6ee824e2d6bc1e1a1707362205c41b4e2bad","user":{"login":"nette","id":99965,"avatar_url":"https://avatars.githubusercontent.com/u/99965?v=3","gravatar_id":"","url":"https://api.github.com/users/nette","html_url":"https://github.com/nette","followers_url":"https://api.github.com/users/nette/followers","following_url":"https://api.github.com/users/nette/following{/other_user}","gists_url":"https://api.github.com/users/nette/gists{/gist_id}","starred_url":"https://api.github.com/users/nette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nette/subscriptions","organizations_url":"https://api.github.com/users/nette/orgs","repos_url":"https://api.github.com/users/nette/repos","events_url":"https://api.github.com/users/nette/events{/privacy}","received_events_url":"https://api.github.com/users/nette/received_events","type":"Organization","site_admin":false},"repo":{"id":17694028,"name":"http","full_name":"nette/http","owner":{"login":"nette","id":99965,"avatar_url":"https://avatars.githubusercontent.com/u/99965?v=3","gravatar_id":"","url":"https://api.github.com/users/nette","html_url":"https://github.com/nette","followers_url":"https://api.github.com/users/nette/followers","following_url":"https://api.github.com/users/nette/following{/other_user}","gists_url":"https://api.github.com/users/nette/gists{/gist_id}","starred_url":"https://api.github.com/users/nette/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nette/subscriptions","organizations_url":"https://api.github.com/users/nette/orgs","repos_url":"https://api.github.com/users/nette/repos","events_url":"https://api.github.com/users/nette/events{/privacy}","received_events_url":"https://api.github.com/users/nette/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nette/http","description":"Nette HTTP: layer for the HTTP request & response","fork":false,"url":"https://api.github.com/repos/nette/http","forks_url":"https://api.github.com/repos/nette/http/forks","keys_url":"https://api.github.com/repos/nette/http/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nette/http/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nette/http/teams","hooks_url":"https://api.github.com/repos/nette/http/hooks","issue_events_url":"https://api.github.com/repos/nette/http/issues/events{/number}","events_url":"https://api.github.com/repos/nette/http/events","assignees_url":"https://api.github.com/repos/nette/http/assignees{/user}","branches_url":"https://api.github.com/repos/nette/http/branches{/branch}","tags_url":"https://api.github.com/repos/nette/http/tags","blobs_url":"https://api.github.com/repos/nette/http/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nette/http/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nette/http/git/refs{/sha}","trees_url":"https://api.github.com/repos/nette/http/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nette/http/statuses/{sha}","languages_url":"https://api.github.com/repos/nette/http/languages","stargazers_url":"https://api.github.com/repos/nette/http/stargazers","contributors_url":"https://api.github.com/repos/nette/http/contributors","subscribers_url":"https://api.github.com/repos/nette/http/subscribers","subscription_url":"https://api.github.com/repos/nette/http/subscription","commits_url":"https://api.github.com/repos/nette/http/commits{/sha}","git_commits_url":"https://api.github.com/repos/nette/http/git/commits{/sha}","comments_url":"https://api.github.com/repos/nette/http/comments{/number}","issue_comment_url":"https://api.github.com/repos/nette/http/issues/comments{/number}","contents_url":"https://api.github.com/repos/nette/http/contents/{+path}","compare_url":"https://api.github.com/repos/nette/http/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nette/http/merges","archive_url":"https://api.github.com/repos/nette/http/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nette/http/downloads","issues_url":"https://api.github.com/repos/nette/http/issues{/number}","pulls_url":"https://api.github.com/repos/nette/http/pulls{/number}","milestones_url":"https://api.github.com/repos/nette/http/milestones{/number}","notifications_url":"https://api.github.com/repos/nette/http/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nette/http/labels{/name}","releases_url":"https://api.github.com/repos/nette/http/releases{/id}","deployments_url":"https://api.github.com/repos/nette/http/deployments","created_at":"2014-03-13T03:46:16Z","updated_at":"2016-01-15T07:58:29Z","pushed_at":"2016-02-01T21:04:11Z","git_url":"git://github.com/nette/http.git","ssh_url":"git@github.com:nette/http.git","clone_url":"https://github.com/nette/http.git","svn_url":"https://github.com/nette/http","homepage":"https://nette.org","size":708,"stargazers_count":63,"watchers_count":63,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":20,"forks":33,"open_issues":20,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nette/http/pulls/81"},"html":{"href":"https://github.com/nette/http/pull/81"},"issue":{"href":"https://api.github.com/repos/nette/http/issues/81"},"comments":{"href":"https://api.github.com/repos/nette/http/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/nette/http/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/nette/http/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nette/http/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/nette/http/statuses/efb2c32c674117b4c1d1917ec00fc312ad9d6d99"}}}}