{"action":"created","comment":{"url":"https://api.github.com/repos/Zewo/Zewo/pulls/comments/81036123","pull_request_review_id":2046621,"id":81036123,"diff_hunk":"@@ -157,36 +157,46 @@ extension Server {\n     }\n \n     public func process(stream: Stream) throws {\n-        let parser = RequestParser(stream: stream, bufferSize: bufferSize)\n+        let chunkBytes = UnsafeMutablePointer<UInt8>.allocate(capacity: bufferSize)\n+        defer { chunkBytes.deallocate(capacity: bufferSize) }\n+        let chunk = UnsafeMutableBufferPointer<UInt8>(start: chunkBytes, count: bufferSize)\n+        \n+        let parser = Parser(mode: .request)\n         let serializer = ResponseSerializer(stream: stream, bufferSize: bufferSize)\n-\n+        \n         while !stream.closed {\n             do {\n-                let request = try parser.parse()\n-                let response = try middleware.chain(to: responder).respond(to: request)\n-                try serializer.serialize(response)\n-\n-                if let upgrade = response.upgradeConnection {\n-                    try upgrade(request, stream)\n-                    stream.close()\n-                }\n-\n-                if !request.isKeepAlive {\n-                    stream.close()\n+                let bytesRead = try stream.read(into: chunk)\n+                let chunkRead = UnsafeBufferPointer(start: chunkBytes, count: bytesRead)\n+                \n+                try parser.parse(chunkRead) { message in\n+                    let request = message as! Request\n+                    let response = try middleware.chain(to: responder).respond(to: request)\n+                    try serializer.serialize(response)\n+                    \n+                    if let upgrade = response.upgradeConnection {\n+                        try upgrade(request, stream)\n+                        stream.close()\n+                    }\n+                    \n+                    if !request.isKeepAlive {\n+                        stream.close()\n+                    }\n                 }\n             } catch SystemError.brokenPipe {\n                 break\n             } catch {\n                 if stream.closed {\n                     break\n                 }\n-\n+                \n                 let (response, unrecoveredError) = Server.recover(error: error)\n                 try serializer.serialize(response)\n-\n+                ","path":"Modules/HTTPServer/Sources/HTTPServer/Server/Server.swift","position":54,"original_position":54,"commit_id":"d32c63806b80189a29c54845b7ccc2aa980393d8","original_commit_id":"d32c63806b80189a29c54845b7ccc2aa980393d8","user":{"login":"robertjpayne","id":214288,"avatar_url":"https://avatars.githubusercontent.com/u/214288?v=3","gravatar_id":"","url":"https://api.github.com/users/robertjpayne","html_url":"https://github.com/robertjpayne","followers_url":"https://api.github.com/users/robertjpayne/followers","following_url":"https://api.github.com/users/robertjpayne/following{/other_user}","gists_url":"https://api.github.com/users/robertjpayne/gists{/gist_id}","starred_url":"https://api.github.com/users/robertjpayne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertjpayne/subscriptions","organizations_url":"https://api.github.com/users/robertjpayne/orgs","repos_url":"https://api.github.com/users/robertjpayne/repos","events_url":"https://api.github.com/users/robertjpayne/events{/privacy}","received_events_url":"https://api.github.com/users/robertjpayne/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2016-09-28T23:05:02Z","updated_at":"2016-09-28T23:05:02Z","html_url":"https://github.com/Zewo/Zewo/pull/162#discussion_r81036123","pull_request_url":"https://api.github.com/repos/Zewo/Zewo/pulls/162","_links":{"self":{"href":"https://api.github.com/repos/Zewo/Zewo/pulls/comments/81036123"},"html":{"href":"https://github.com/Zewo/Zewo/pull/162#discussion_r81036123"},"pull_request":{"href":"https://api.github.com/repos/Zewo/Zewo/pulls/162"}}},"pull_request":{"url":"https://api.github.com/repos/Zewo/Zewo/pulls/162","id":86874552,"html_url":"https://github.com/Zewo/Zewo/pull/162","diff_url":"https://github.com/Zewo/Zewo/pull/162.diff","patch_url":"https://github.com/Zewo/Zewo/pull/162.patch","issue_url":"https://api.github.com/repos/Zewo/Zewo/issues/162","number":162,"state":"open","locked":false,"title":"Performance Round Two","user":{"login":"robertjpayne","id":214288,"avatar_url":"https://avatars.githubusercontent.com/u/214288?v=3","gravatar_id":"","url":"https://api.github.com/users/robertjpayne","html_url":"https://github.com/robertjpayne","followers_url":"https://api.github.com/users/robertjpayne/followers","following_url":"https://api.github.com/users/robertjpayne/following{/other_user}","gists_url":"https://api.github.com/users/robertjpayne/gists{/gist_id}","starred_url":"https://api.github.com/users/robertjpayne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertjpayne/subscriptions","organizations_url":"https://api.github.com/users/robertjpayne/orgs","repos_url":"https://api.github.com/users/robertjpayne/repos","events_url":"https://api.github.com/users/robertjpayne/events{/privacy}","received_events_url":"https://api.github.com/users/robertjpayne/received_events","type":"User","site_admin":false},"body":"@Danappelxx @paulofaria \r\n\r\nThis PR includes several changes again to address performance:\r\n\r\n* Merges HTTP Request+Response into one\r\n* Adds `Parser` protocol\r\n* Buffer is now our own struct rather than backed by DispatchData and under the hood it uses [UInt8]","created_at":"2016-09-27T07:22:11Z","updated_at":"2016-09-28T23:05:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64f156f2cf3df50f29556653ec89d73d65644af3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Zewo/Zewo/pulls/162/commits","review_comments_url":"https://api.github.com/repos/Zewo/Zewo/pulls/162/comments","review_comment_url":"https://api.github.com/repos/Zewo/Zewo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Zewo/Zewo/issues/162/comments","statuses_url":"https://api.github.com/repos/Zewo/Zewo/statuses/d32c63806b80189a29c54845b7ccc2aa980393d8","head":{"label":"Zewo:feature/merged-http-parsers","ref":"feature/merged-http-parsers","sha":"d32c63806b80189a29c54845b7ccc2aa980393d8","user":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"repo":{"id":45657428,"name":"Zewo","full_name":"Zewo/Zewo","owner":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Zewo/Zewo","description":"Open source Swift libraries for modern server software.","fork":false,"url":"https://api.github.com/repos/Zewo/Zewo","forks_url":"https://api.github.com/repos/Zewo/Zewo/forks","keys_url":"https://api.github.com/repos/Zewo/Zewo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zewo/Zewo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zewo/Zewo/teams","hooks_url":"https://api.github.com/repos/Zewo/Zewo/hooks","issue_events_url":"https://api.github.com/repos/Zewo/Zewo/issues/events{/number}","events_url":"https://api.github.com/repos/Zewo/Zewo/events","assignees_url":"https://api.github.com/repos/Zewo/Zewo/assignees{/user}","branches_url":"https://api.github.com/repos/Zewo/Zewo/branches{/branch}","tags_url":"https://api.github.com/repos/Zewo/Zewo/tags","blobs_url":"https://api.github.com/repos/Zewo/Zewo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zewo/Zewo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zewo/Zewo/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zewo/Zewo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zewo/Zewo/statuses/{sha}","languages_url":"https://api.github.com/repos/Zewo/Zewo/languages","stargazers_url":"https://api.github.com/repos/Zewo/Zewo/stargazers","contributors_url":"https://api.github.com/repos/Zewo/Zewo/contributors","subscribers_url":"https://api.github.com/repos/Zewo/Zewo/subscribers","subscription_url":"https://api.github.com/repos/Zewo/Zewo/subscription","commits_url":"https://api.github.com/repos/Zewo/Zewo/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zewo/Zewo/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zewo/Zewo/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zewo/Zewo/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zewo/Zewo/contents/{+path}","compare_url":"https://api.github.com/repos/Zewo/Zewo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zewo/Zewo/merges","archive_url":"https://api.github.com/repos/Zewo/Zewo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zewo/Zewo/downloads","issues_url":"https://api.github.com/repos/Zewo/Zewo/issues{/number}","pulls_url":"https://api.github.com/repos/Zewo/Zewo/pulls{/number}","milestones_url":"https://api.github.com/repos/Zewo/Zewo/milestones{/number}","notifications_url":"https://api.github.com/repos/Zewo/Zewo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zewo/Zewo/labels{/name}","releases_url":"https://api.github.com/repos/Zewo/Zewo/releases{/id}","deployments_url":"https://api.github.com/repos/Zewo/Zewo/deployments","created_at":"2015-11-06T03:41:36Z","updated_at":"2016-09-28T22:19:54Z","pushed_at":"2016-09-28T22:08:55Z","git_url":"git://github.com/Zewo/Zewo.git","ssh_url":"git@github.com:Zewo/Zewo.git","clone_url":"https://github.com/Zewo/Zewo.git","svn_url":"https://github.com/Zewo/Zewo","homepage":"http://zewo.io","size":3537,"stargazers_count":1293,"watchers_count":1293,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":43,"forks":75,"open_issues":43,"watchers":1293,"default_branch":"master"}},"base":{"label":"Zewo:master","ref":"master","sha":"50c1a138fbdb9df4785975af2e6ecba9afd170d2","user":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"repo":{"id":45657428,"name":"Zewo","full_name":"Zewo/Zewo","owner":{"login":"Zewo","id":12739462,"avatar_url":"https://avatars.githubusercontent.com/u/12739462?v=3","gravatar_id":"","url":"https://api.github.com/users/Zewo","html_url":"https://github.com/Zewo","followers_url":"https://api.github.com/users/Zewo/followers","following_url":"https://api.github.com/users/Zewo/following{/other_user}","gists_url":"https://api.github.com/users/Zewo/gists{/gist_id}","starred_url":"https://api.github.com/users/Zewo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zewo/subscriptions","organizations_url":"https://api.github.com/users/Zewo/orgs","repos_url":"https://api.github.com/users/Zewo/repos","events_url":"https://api.github.com/users/Zewo/events{/privacy}","received_events_url":"https://api.github.com/users/Zewo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Zewo/Zewo","description":"Open source Swift libraries for modern server software.","fork":false,"url":"https://api.github.com/repos/Zewo/Zewo","forks_url":"https://api.github.com/repos/Zewo/Zewo/forks","keys_url":"https://api.github.com/repos/Zewo/Zewo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zewo/Zewo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zewo/Zewo/teams","hooks_url":"https://api.github.com/repos/Zewo/Zewo/hooks","issue_events_url":"https://api.github.com/repos/Zewo/Zewo/issues/events{/number}","events_url":"https://api.github.com/repos/Zewo/Zewo/events","assignees_url":"https://api.github.com/repos/Zewo/Zewo/assignees{/user}","branches_url":"https://api.github.com/repos/Zewo/Zewo/branches{/branch}","tags_url":"https://api.github.com/repos/Zewo/Zewo/tags","blobs_url":"https://api.github.com/repos/Zewo/Zewo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zewo/Zewo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zewo/Zewo/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zewo/Zewo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zewo/Zewo/statuses/{sha}","languages_url":"https://api.github.com/repos/Zewo/Zewo/languages","stargazers_url":"https://api.github.com/repos/Zewo/Zewo/stargazers","contributors_url":"https://api.github.com/repos/Zewo/Zewo/contributors","subscribers_url":"https://api.github.com/repos/Zewo/Zewo/subscribers","subscription_url":"https://api.github.com/repos/Zewo/Zewo/subscription","commits_url":"https://api.github.com/repos/Zewo/Zewo/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zewo/Zewo/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zewo/Zewo/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zewo/Zewo/issues/comments{/number}","contents_url":"https://api.github.com/repos/Zewo/Zewo/contents/{+path}","compare_url":"https://api.github.com/repos/Zewo/Zewo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zewo/Zewo/merges","archive_url":"https://api.github.com/repos/Zewo/Zewo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zewo/Zewo/downloads","issues_url":"https://api.github.com/repos/Zewo/Zewo/issues{/number}","pulls_url":"https://api.github.com/repos/Zewo/Zewo/pulls{/number}","milestones_url":"https://api.github.com/repos/Zewo/Zewo/milestones{/number}","notifications_url":"https://api.github.com/repos/Zewo/Zewo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zewo/Zewo/labels{/name}","releases_url":"https://api.github.com/repos/Zewo/Zewo/releases{/id}","deployments_url":"https://api.github.com/repos/Zewo/Zewo/deployments","created_at":"2015-11-06T03:41:36Z","updated_at":"2016-09-28T22:19:54Z","pushed_at":"2016-09-28T22:08:55Z","git_url":"git://github.com/Zewo/Zewo.git","ssh_url":"git@github.com:Zewo/Zewo.git","clone_url":"https://github.com/Zewo/Zewo.git","svn_url":"https://github.com/Zewo/Zewo","homepage":"http://zewo.io","size":3537,"stargazers_count":1293,"watchers_count":1293,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":75,"mirror_url":null,"open_issues_count":43,"forks":75,"open_issues":43,"watchers":1293,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Zewo/Zewo/pulls/162"},"html":{"href":"https://github.com/Zewo/Zewo/pull/162"},"issue":{"href":"https://api.github.com/repos/Zewo/Zewo/issues/162"},"comments":{"href":"https://api.github.com/repos/Zewo/Zewo/issues/162/comments"},"review_comments":{"href":"https://api.github.com/repos/Zewo/Zewo/pulls/162/comments"},"review_comment":{"href":"https://api.github.com/repos/Zewo/Zewo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Zewo/Zewo/pulls/162/commits"},"statuses":{"href":"https://api.github.com/repos/Zewo/Zewo/statuses/d32c63806b80189a29c54845b7ccc2aa980393d8"}}}}
{"actor":{"display_login":"robertjpayne"}}