{"action":"created","comment":{"url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/comments/83812381","pull_request_review_id":4629656,"id":83812381,"diff_hunk":"@@ -34,30 +34,29 @@ public function request($action, array $data)\n                 throw new RequesterException('Failed to serialize data into JSON. Data: ' . var_export($data, true));\n             }\n \n-            $urlParts = parse_url($this->endpoint->getUrl() . $action);\n-            $scheme = isset($urlParts['scheme']) && $urlParts['scheme'] === 'https' ? 'ssl://' : '';\n-            $port = isset($urlParts['port']) ? $urlParts['port'] : ($urlParts['scheme'] === 'https' ? 443 : 80);\n-            $fp = fsockopen($scheme . $urlParts['host'], $port, $errorNo, $errorMessage);\n+            $options = [\n+                'http' => [\n+                    'method' => \"POST\",\n+                    'header' => \"Content-Type: application/json\\r\\n\" . sprintf(\"Content-Length: %d\\r\\n\", strlen($json)),\n+                    'content' => $json,\n+                    'ignore_errors' => true\n+                ]\n+            ];\n+\n+            $context = stream_context_create($options);\n+            $fp = fopen($this->endpoint->getUrl() . $action, 'r', false, $context);\n+\n             if ($fp === false) {\n-                throw new RequesterException(sprintf('fsockopen failed: [%d] %s', $errorNo, $errorMessage));\n+                throw new RequesterException(sprintf('fopen failed'));\n             }\n \n-            $path = $urlParts['path'] . (isset($urlParts['query']) ? '?' . $urlParts['query'] : '');\n-            fwrite($fp, sprintf(\"POST %s HTTP/1.1\\r\\n\", $path));\n-            fwrite($fp, sprintf(\"Host: %s\\r\\n\", $urlParts['host']));\n-            fwrite($fp, \"Content-Type: application/json\\r\\n\");\n-            fwrite($fp, sprintf(\"Content-Length: %d\\r\\n\", strlen($json)));\n-            fwrite($fp, \"Connection: close\\r\\n\");\n-            fwrite($fp, \"\\r\\n\");\n-            fwrite($fp, $json);\n-\n-            $response = stream_get_contents($fp);\n+            $result = stream_get_contents($fp);\n             fclose($fp);\n \n-            list($headers, $result) = explode(\"\\r\\n\\r\\n\", $response, 2);\n-            list($statusHeader, $_) = explode(\"\\r\\n\", $headers, 2);\n-            list($version, $httpCode, $phrase) = explode(' ', $statusHeader, 3);\n-            $httpCode = (int)$httpCode;\n+            $matches = [];\n+            preg_match('/\\\"code\\\": (\\d+),/', $result, $matches);\n+            $httpCode = (int)$matches[1];\n+","path":"src/ShopCertification/PhpRequester.php","position":45,"original_position":45,"commit_id":"05841730ea8ad5bffa7404669cd3bb2f7976f3d8","original_commit_id":"05841730ea8ad5bffa7404669cd3bb2f7976f3d8","user":{"login":"MiroslavHlavka","id":5640299,"avatar_url":"https://avatars.githubusercontent.com/u/5640299?v=3","gravatar_id":"","url":"https://api.github.com/users/MiroslavHlavka","html_url":"https://github.com/MiroslavHlavka","followers_url":"https://api.github.com/users/MiroslavHlavka/followers","following_url":"https://api.github.com/users/MiroslavHlavka/following{/other_user}","gists_url":"https://api.github.com/users/MiroslavHlavka/gists{/gist_id}","starred_url":"https://api.github.com/users/MiroslavHlavka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiroslavHlavka/subscriptions","organizations_url":"https://api.github.com/users/MiroslavHlavka/orgs","repos_url":"https://api.github.com/users/MiroslavHlavka/repos","events_url":"https://api.github.com/users/MiroslavHlavka/events{/privacy}","received_events_url":"https://api.github.com/users/MiroslavHlavka/received_events","type":"User","site_admin":false},"body":"Právě, že né. Do toho result se teď dává pouze ten obsah ... bez hlaviček proto tak složitě získávám ten httpCode :/","created_at":"2016-10-18T09:15:20Z","updated_at":"2016-10-18T09:15:20Z","html_url":"https://github.com/heureka/overeno-zakazniky/pull/22#discussion_r83812381","pull_request_url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/comments/83812381"},"html":{"href":"https://github.com/heureka/overeno-zakazniky/pull/22#discussion_r83812381"},"pull_request":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22","id":89600184,"html_url":"https://github.com/heureka/overeno-zakazniky/pull/22","diff_url":"https://github.com/heureka/overeno-zakazniky/pull/22.diff","patch_url":"https://github.com/heureka/overeno-zakazniky/pull/22.patch","issue_url":"https://api.github.com/repos/heureka/overeno-zakazniky/issues/22","number":22,"state":"open","locked":false,"title":"Fix malformed body response in PhpRequester","user":{"login":"MiroslavHlavka","id":5640299,"avatar_url":"https://avatars.githubusercontent.com/u/5640299?v=3","gravatar_id":"","url":"https://api.github.com/users/MiroslavHlavka","html_url":"https://github.com/MiroslavHlavka","followers_url":"https://api.github.com/users/MiroslavHlavka/followers","following_url":"https://api.github.com/users/MiroslavHlavka/following{/other_user}","gists_url":"https://api.github.com/users/MiroslavHlavka/gists{/gist_id}","starred_url":"https://api.github.com/users/MiroslavHlavka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiroslavHlavka/subscriptions","organizations_url":"https://api.github.com/users/MiroslavHlavka/orgs","repos_url":"https://api.github.com/users/MiroslavHlavka/repos","events_url":"https://api.github.com/users/MiroslavHlavka/events{/privacy}","received_events_url":"https://api.github.com/users/MiroslavHlavka/received_events","type":"User","site_admin":false},"body":"use stream_context_create","created_at":"2016-10-17T10:47:53Z","updated_at":"2016-10-18T09:15:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a5807e4bdc519cbd51b9345f30a7f206ca63bcc9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22/commits","review_comments_url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22/comments","review_comment_url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/comments{/number}","comments_url":"https://api.github.com/repos/heureka/overeno-zakazniky/issues/22/comments","statuses_url":"https://api.github.com/repos/heureka/overeno-zakazniky/statuses/05841730ea8ad5bffa7404669cd3bb2f7976f3d8","head":{"label":"MiroslavHlavka:fix-malformed-body-response-in-PhpRequester","ref":"fix-malformed-body-response-in-PhpRequester","sha":"05841730ea8ad5bffa7404669cd3bb2f7976f3d8","user":{"login":"MiroslavHlavka","id":5640299,"avatar_url":"https://avatars.githubusercontent.com/u/5640299?v=3","gravatar_id":"","url":"https://api.github.com/users/MiroslavHlavka","html_url":"https://github.com/MiroslavHlavka","followers_url":"https://api.github.com/users/MiroslavHlavka/followers","following_url":"https://api.github.com/users/MiroslavHlavka/following{/other_user}","gists_url":"https://api.github.com/users/MiroslavHlavka/gists{/gist_id}","starred_url":"https://api.github.com/users/MiroslavHlavka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiroslavHlavka/subscriptions","organizations_url":"https://api.github.com/users/MiroslavHlavka/orgs","repos_url":"https://api.github.com/users/MiroslavHlavka/repos","events_url":"https://api.github.com/users/MiroslavHlavka/events{/privacy}","received_events_url":"https://api.github.com/users/MiroslavHlavka/received_events","type":"User","site_admin":false},"repo":{"id":70893962,"name":"overeno-zakazniky","full_name":"MiroslavHlavka/overeno-zakazniky","owner":{"login":"MiroslavHlavka","id":5640299,"avatar_url":"https://avatars.githubusercontent.com/u/5640299?v=3","gravatar_id":"","url":"https://api.github.com/users/MiroslavHlavka","html_url":"https://github.com/MiroslavHlavka","followers_url":"https://api.github.com/users/MiroslavHlavka/followers","following_url":"https://api.github.com/users/MiroslavHlavka/following{/other_user}","gists_url":"https://api.github.com/users/MiroslavHlavka/gists{/gist_id}","starred_url":"https://api.github.com/users/MiroslavHlavka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MiroslavHlavka/subscriptions","organizations_url":"https://api.github.com/users/MiroslavHlavka/orgs","repos_url":"https://api.github.com/users/MiroslavHlavka/repos","events_url":"https://api.github.com/users/MiroslavHlavka/events{/privacy}","received_events_url":"https://api.github.com/users/MiroslavHlavka/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MiroslavHlavka/overeno-zakazniky","description":"Heureka overeno service API for PHP","fork":true,"url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky","forks_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/forks","keys_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/teams","hooks_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/hooks","issue_events_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/issues/events{/number}","events_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/events","assignees_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/assignees{/user}","branches_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/branches{/branch}","tags_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/tags","blobs_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/git/refs{/sha}","trees_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/statuses/{sha}","languages_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/languages","stargazers_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/stargazers","contributors_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/contributors","subscribers_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/subscribers","subscription_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/subscription","commits_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/commits{/sha}","git_commits_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/git/commits{/sha}","comments_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/comments{/number}","issue_comment_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/issues/comments{/number}","contents_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/contents/{+path}","compare_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/merges","archive_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/downloads","issues_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/issues{/number}","pulls_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/pulls{/number}","milestones_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/milestones{/number}","notifications_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/labels{/name}","releases_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/releases{/id}","deployments_url":"https://api.github.com/repos/MiroslavHlavka/overeno-zakazniky/deployments","created_at":"2016-10-14T09:13:44Z","updated_at":"2016-10-14T09:13:46Z","pushed_at":"2016-10-17T08:07:49Z","git_url":"git://github.com/MiroslavHlavka/overeno-zakazniky.git","ssh_url":"git@github.com:MiroslavHlavka/overeno-zakazniky.git","clone_url":"https://github.com/MiroslavHlavka/overeno-zakazniky.git","svn_url":"https://github.com/MiroslavHlavka/overeno-zakazniky","homepage":null,"size":36,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"heureka:master","ref":"master","sha":"f3ed058116e7a4cca5bf314f59f2856ba6cd2b76","user":{"login":"heureka","id":3062430,"avatar_url":"https://avatars.githubusercontent.com/u/3062430?v=3","gravatar_id":"","url":"https://api.github.com/users/heureka","html_url":"https://github.com/heureka","followers_url":"https://api.github.com/users/heureka/followers","following_url":"https://api.github.com/users/heureka/following{/other_user}","gists_url":"https://api.github.com/users/heureka/gists{/gist_id}","starred_url":"https://api.github.com/users/heureka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heureka/subscriptions","organizations_url":"https://api.github.com/users/heureka/orgs","repos_url":"https://api.github.com/users/heureka/repos","events_url":"https://api.github.com/users/heureka/events{/privacy}","received_events_url":"https://api.github.com/users/heureka/received_events","type":"Organization","site_admin":false},"repo":{"id":9955569,"name":"overeno-zakazniky","full_name":"heureka/overeno-zakazniky","owner":{"login":"heureka","id":3062430,"avatar_url":"https://avatars.githubusercontent.com/u/3062430?v=3","gravatar_id":"","url":"https://api.github.com/users/heureka","html_url":"https://github.com/heureka","followers_url":"https://api.github.com/users/heureka/followers","following_url":"https://api.github.com/users/heureka/following{/other_user}","gists_url":"https://api.github.com/users/heureka/gists{/gist_id}","starred_url":"https://api.github.com/users/heureka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heureka/subscriptions","organizations_url":"https://api.github.com/users/heureka/orgs","repos_url":"https://api.github.com/users/heureka/repos","events_url":"https://api.github.com/users/heureka/events{/privacy}","received_events_url":"https://api.github.com/users/heureka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/heureka/overeno-zakazniky","description":"Heureka overeno service API for PHP","fork":false,"url":"https://api.github.com/repos/heureka/overeno-zakazniky","forks_url":"https://api.github.com/repos/heureka/overeno-zakazniky/forks","keys_url":"https://api.github.com/repos/heureka/overeno-zakazniky/keys{/key_id}","collaborators_url":"https://api.github.com/repos/heureka/overeno-zakazniky/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/heureka/overeno-zakazniky/teams","hooks_url":"https://api.github.com/repos/heureka/overeno-zakazniky/hooks","issue_events_url":"https://api.github.com/repos/heureka/overeno-zakazniky/issues/events{/number}","events_url":"https://api.github.com/repos/heureka/overeno-zakazniky/events","assignees_url":"https://api.github.com/repos/heureka/overeno-zakazniky/assignees{/user}","branches_url":"https://api.github.com/repos/heureka/overeno-zakazniky/branches{/branch}","tags_url":"https://api.github.com/repos/heureka/overeno-zakazniky/tags","blobs_url":"https://api.github.com/repos/heureka/overeno-zakazniky/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/heureka/overeno-zakazniky/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/heureka/overeno-zakazniky/git/refs{/sha}","trees_url":"https://api.github.com/repos/heureka/overeno-zakazniky/git/trees{/sha}","statuses_url":"https://api.github.com/repos/heureka/overeno-zakazniky/statuses/{sha}","languages_url":"https://api.github.com/repos/heureka/overeno-zakazniky/languages","stargazers_url":"https://api.github.com/repos/heureka/overeno-zakazniky/stargazers","contributors_url":"https://api.github.com/repos/heureka/overeno-zakazniky/contributors","subscribers_url":"https://api.github.com/repos/heureka/overeno-zakazniky/subscribers","subscription_url":"https://api.github.com/repos/heureka/overeno-zakazniky/subscription","commits_url":"https://api.github.com/repos/heureka/overeno-zakazniky/commits{/sha}","git_commits_url":"https://api.github.com/repos/heureka/overeno-zakazniky/git/commits{/sha}","comments_url":"https://api.github.com/repos/heureka/overeno-zakazniky/comments{/number}","issue_comment_url":"https://api.github.com/repos/heureka/overeno-zakazniky/issues/comments{/number}","contents_url":"https://api.github.com/repos/heureka/overeno-zakazniky/contents/{+path}","compare_url":"https://api.github.com/repos/heureka/overeno-zakazniky/compare/{base}...{head}","merges_url":"https://api.github.com/repos/heureka/overeno-zakazniky/merges","archive_url":"https://api.github.com/repos/heureka/overeno-zakazniky/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/heureka/overeno-zakazniky/downloads","issues_url":"https://api.github.com/repos/heureka/overeno-zakazniky/issues{/number}","pulls_url":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls{/number}","milestones_url":"https://api.github.com/repos/heureka/overeno-zakazniky/milestones{/number}","notifications_url":"https://api.github.com/repos/heureka/overeno-zakazniky/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/heureka/overeno-zakazniky/labels{/name}","releases_url":"https://api.github.com/repos/heureka/overeno-zakazniky/releases{/id}","deployments_url":"https://api.github.com/repos/heureka/overeno-zakazniky/deployments","created_at":"2013-05-09T08:42:04Z","updated_at":"2016-09-24T16:17:09Z","pushed_at":"2016-10-17T10:47:53Z","git_url":"git://github.com/heureka/overeno-zakazniky.git","ssh_url":"git@github.com:heureka/overeno-zakazniky.git","clone_url":"https://github.com/heureka/overeno-zakazniky.git","svn_url":"https://github.com/heureka/overeno-zakazniky","homepage":null,"size":38,"stargazers_count":16,"watchers_count":16,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":2,"forks":20,"open_issues":2,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22"},"html":{"href":"https://github.com/heureka/overeno-zakazniky/pull/22"},"issue":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/issues/22"},"comments":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/heureka/overeno-zakazniky/statuses/05841730ea8ad5bffa7404669cd3bb2f7976f3d8"}}}}
{"actor":{"display_login":"MiroslavHlavka"}}