{"action":"created","issue":{"url":"https://api.github.com/repos/neomerx/cors-psr7/issues/28","repository_url":"https://api.github.com/repos/neomerx/cors-psr7","labels_url":"https://api.github.com/repos/neomerx/cors-psr7/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/neomerx/cors-psr7/issues/28/comments","events_url":"https://api.github.com/repos/neomerx/cors-psr7/issues/28/events","html_url":"https://github.com/neomerx/cors-psr7/issues/28","id":325653739,"number":28,"title":"In some cases it incorrectly checks `Host` header","user":{"login":"starx","id":1029450,"avatar_url":"https://avatars2.githubusercontent.com/u/1029450?v=4","gravatar_id":"","url":"https://api.github.com/users/starx","html_url":"https://github.com/starx","followers_url":"https://api.github.com/users/starx/followers","following_url":"https://api.github.com/users/starx/following{/other_user}","gists_url":"https://api.github.com/users/starx/gists{/gist_id}","starred_url":"https://api.github.com/users/starx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starx/subscriptions","organizations_url":"https://api.github.com/users/starx/orgs","repos_url":"https://api.github.com/users/starx/repos","events_url":"https://api.github.com/users/starx/events{/privacy}","received_events_url":"https://api.github.com/users/starx/received_events","type":"User","site_admin":false},"labels":[{"id":244673111,"url":"https://api.github.com/repos/neomerx/cors-psr7/labels/bug","name":"bug","color":"fc2929","default":true},{"id":245076064,"url":"https://api.github.com/repos/neomerx/cors-psr7/labels/fixed","name":"fixed","color":"009800","default":false}],"state":"open","locked":false,"assignee":{"login":"neomerx","id":10420662,"avatar_url":"https://avatars0.githubusercontent.com/u/10420662?v=4","gravatar_id":"","url":"https://api.github.com/users/neomerx","html_url":"https://github.com/neomerx","followers_url":"https://api.github.com/users/neomerx/followers","following_url":"https://api.github.com/users/neomerx/following{/other_user}","gists_url":"https://api.github.com/users/neomerx/gists{/gist_id}","starred_url":"https://api.github.com/users/neomerx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neomerx/subscriptions","organizations_url":"https://api.github.com/users/neomerx/orgs","repos_url":"https://api.github.com/users/neomerx/repos","events_url":"https://api.github.com/users/neomerx/events{/privacy}","received_events_url":"https://api.github.com/users/neomerx/received_events","type":"User","site_admin":false},"assignees":[{"login":"neomerx","id":10420662,"avatar_url":"https://avatars0.githubusercontent.com/u/10420662?v=4","gravatar_id":"","url":"https://api.github.com/users/neomerx","html_url":"https://github.com/neomerx","followers_url":"https://api.github.com/users/neomerx/followers","following_url":"https://api.github.com/users/neomerx/following{/other_user}","gists_url":"https://api.github.com/users/neomerx/gists{/gist_id}","starred_url":"https://api.github.com/users/neomerx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neomerx/subscriptions","organizations_url":"https://api.github.com/users/neomerx/orgs","repos_url":"https://api.github.com/users/neomerx/repos","events_url":"https://api.github.com/users/neomerx/events{/privacy}","received_events_url":"https://api.github.com/users/neomerx/received_events","type":"User","site_admin":false}],"milestone":null,"comments":12,"created_at":"2018-05-23T10:57:30Z","updated_at":"2018-05-23T20:33:10Z","closed_at":null,"author_association":"NONE","body":"I am trying to implement this as a middleware on Silex Framework (version 2). Silex by default does not support PSR 7 request and responses, so I use [DiactorosFactory](https://github.com/symfony/psr-http-message-bridge) Library to convert the Symfony Foundation Request/Response to & from PSR 7 Request and Response.\r\n\r\nIn the CORS Settings, I have something like this\r\n\r\n    ->setServerOrigin([\r\n        'scheme' => 'http',\r\n        'host'   => 'www.something.test',\r\n        'port'   => 80,\r\n    ])\r\n\r\nAnd the check fails even when the call is made to the host that is configured above i.e. `www.something.test`.\r\n\r\nI am making a preflight request to `http://www.something.test` and when it comes to `Analyzer.php`'s `isSameHost` method `$host` get's value of `www.something.test` and `$hostURL` which should be parsed object, has `host` property as null. \r\n\r\nhttps://github.com/neomerx/cors-psr7/blob/24944f39483d1a89f66ae9d58cca9f82b8815b35/src/Analyzer.php#L320\r\n\r\nThis is the because internally it uses php's function `parse_url` to parse url if it is string.\r\n\r\nhttps://github.com/neomerx/cors-psr7/blob/24944f39483d1a89f66ae9d58cca9f82b8815b35/src/Http/ParsedUrl.php#L64\r\n\r\nand after parsing `www.something.test` returns array which looks like \r\n\r\n\tarray(..) {\r\n\t  [\"path\"]=>\r\n\t  string(5) \"www.something.test\"\r\n\t}\r\n\r\nand thus does not have enough information to match the host.\r\n\r\nhttps://github.com/neomerx/cors-psr7/blob/24944f39483d1a89f66ae9d58cca9f82b8815b35/src/Http/ParsedUrl.php#L71-L73\r\n\r\nI am not sure why\r\n\r\nhttps://github.com/neomerx/cors-psr7/blob/24944f39483d1a89f66ae9d58cca9f82b8815b35/src/Analyzer.php#L320-L321\r\n\r\n`$host` where which returns `www.something.test` passed to `createParsedURL`  as it does not have enough data to properly parse all the request.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/neomerx/cors-psr7/issues/comments/391486816","html_url":"https://github.com/neomerx/cors-psr7/issues/28#issuecomment-391486816","issue_url":"https://api.github.com/repos/neomerx/cors-psr7/issues/28","id":391486816,"user":{"login":"starx","id":1029450,"avatar_url":"https://avatars2.githubusercontent.com/u/1029450?v=4","gravatar_id":"","url":"https://api.github.com/users/starx","html_url":"https://github.com/starx","followers_url":"https://api.github.com/users/starx/followers","following_url":"https://api.github.com/users/starx/following{/other_user}","gists_url":"https://api.github.com/users/starx/gists{/gist_id}","starred_url":"https://api.github.com/users/starx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/starx/subscriptions","organizations_url":"https://api.github.com/users/starx/orgs","repos_url":"https://api.github.com/users/starx/repos","events_url":"https://api.github.com/users/starx/events{/privacy}","received_events_url":"https://api.github.com/users/starx/received_events","type":"User","site_admin":false},"created_at":"2018-05-23T20:33:09Z","updated_at":"2018-05-23T20:33:09Z","author_association":"NONE","body":"Actually, I can see that port is only checked if it is set in the settings as you said in the previous comment (I forgot that). Please, consider my question answered. 😄 "}}
{"actor":{"display_login":"starx"}}