{"action":"created","comment":{"url":"https://api.github.com/repos/joedevivo/chatterbox/pulls/comments/58948310","id":58948310,"diff_hunk":"@@ -91,3 +83,74 @@ from_frames([], Acc) ->\n     Acc;\n from_frames([{#frame_header{type=?CONTINUATION},#continuation{block_fragment=BF}}|Continuations], Acc) ->\n     from_frames(Continuations, <<Acc/binary,BF/binary>>).\n+\n+-spec split(Binary::binary(),\n+            MaxFrameSize::pos_integer()) ->\n+                   [binary()].\n+split(Binary, MaxFrameSize) ->\n+    split(Binary, MaxFrameSize, []).\n+\n+-spec split(Binary::binary(),\n+            MaxFrameSize::pos_integer(),\n+            [binary()]) ->\n+                   [binary()].\n+split(Binary, MaxFrameSize, Acc)\n+  when byte_size(Binary) =< MaxFrameSize ->\n+    lists:reverse([Binary|Acc]);\n+split(Binary, MaxFrameSize, Acc) ->\n+    <<NextFrame:MaxFrameSize/binary,Remaining/binary>> = Binary,\n+    split(Remaining, MaxFrameSize, [NextFrame|Acc]).\n+\n+%% Now build frames.\n+%% The first will be a HEADERS frame, followed by CONTINUATION\n+%% If EndStream, that flag needs to be set on the first frame\n+%% ?FLAG_END_HEADERS needs to be set on the last.\n+%% If there's only one, it needs to be set on both.\n+-spec build_frames(StreamId :: stream_id(),\n+                   Chunks::[binary()],\n+                   EndStream::boolean()) ->\n+                          [frame()].\n+build_frames(StreamId, [FirstChunk|Rest], EndStream) ->\n+    Flag = case EndStream of\n+               true ->\n+                   ?FLAG_END_STREAM;\n+               false ->\n+                   0\n+           end,\n+    HeadersFrame =\n+        { #frame_header{\n+             type=?HEADERS,\n+             flags=Flag,\n+             length=byte_size(FirstChunk),\n+             stream_id=StreamId},\n+          #headers{\n+             block_fragment=FirstChunk}},\n+    [{LastFrameHeader, LastFrameBody}|Frames] =\n+        build_frames_(StreamId, Rest, [HeadersFrame]),\n+    NewLastFrame = {\n+      LastFrameHeader#frame_header{\n+        flags=LastFrameHeader#frame_header.flags bor ?FLAG_END_HEADERS\n+       },\n+      LastFrameBody},\n+\n+    lists:reverse([NewLastFrame|Frames]).\n+\n+-spec build_frames_(StreamId::stream_id(),\n+                    Chunks::[binary()],\n+                    Acc::[frame()])->\n+                           [frame()].\n+build_frames_(_StreamId, [], Acc) ->","path":"src/http2_frame_headers.erl","position":113,"original_position":113,"commit_id":"35b82e235d8770ef11741647cc7a5cd62db6b515","original_commit_id":"35b82e235d8770ef11741647cc7a5cd62db6b515","user":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"body":"I'd still have it broken up into different functions because the initial caller shouldn't be responsible for setting up the accumulator","created_at":"2016-04-07T21:28:08Z","updated_at":"2016-04-07T21:28:08Z","html_url":"https://github.com/joedevivo/chatterbox/pull/36#discussion_r58948310","pull_request_url":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/joedevivo/chatterbox/pulls/comments/58948310"},"html":{"href":"https://github.com/joedevivo/chatterbox/pull/36#discussion_r58948310"},"pull_request":{"href":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36","id":65660990,"html_url":"https://github.com/joedevivo/chatterbox/pull/36","diff_url":"https://github.com/joedevivo/chatterbox/pull/36.diff","patch_url":"https://github.com/joedevivo/chatterbox/pull/36.patch","issue_url":"https://api.github.com/repos/joedevivo/chatterbox/issues/36","number":36,"state":"open","locked":false,"title":"8.1. HTTP Request/Response Exchange: Sends a HEADERS frame as HEAD request","user":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"body":"```\r\n8.1. HTTP Request/Response Exchange\r\n    × Sends a HEADERS frame as HEAD request\r\n      - The endpoint should respond with no DATA frame or empty DATA frame.\r\n        Expected: HEADERS frame (Flags: 1)\r\n                  DATA frame (Length: 0, Flags: 1)\r\n          Actual: DATA frame (Length: 16, Flags: 1)\r\n```","created_at":"2016-04-07T16:36:10Z","updated_at":"2016-04-07T21:28:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bdbfbe4039c27ffd5a25ac4b0c2f985dd82e4d3e","assignee":null,"milestone":{"url":"https://api.github.com/repos/joedevivo/chatterbox/milestones/1","html_url":"https://github.com/joedevivo/chatterbox/milestones/h2spec","labels_url":"https://api.github.com/repos/joedevivo/chatterbox/milestones/1/labels","id":1659836,"number":1,"title":"h2spec","description":null,"creator":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":26,"state":"open","created_at":"2016-03-22T14:37:59Z","updated_at":"2016-04-07T14:49:40Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36/commits","review_comments_url":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36/comments","review_comment_url":"https://api.github.com/repos/joedevivo/chatterbox/pulls/comments{/number}","comments_url":"https://api.github.com/repos/joedevivo/chatterbox/issues/36/comments","statuses_url":"https://api.github.com/repos/joedevivo/chatterbox/statuses/35b82e235d8770ef11741647cc7a5cd62db6b515","head":{"label":"joedevivo:head-req","ref":"head-req","sha":"35b82e235d8770ef11741647cc7a5cd62db6b515","user":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"repo":{"id":33418317,"name":"chatterbox","full_name":"joedevivo/chatterbox","owner":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joedevivo/chatterbox","description":"HTTP/2 Server for Erlang. Boy, that guy was a real chatterbox waddn't he?  I didn't think he was ever going to stop with the story.","fork":false,"url":"https://api.github.com/repos/joedevivo/chatterbox","forks_url":"https://api.github.com/repos/joedevivo/chatterbox/forks","keys_url":"https://api.github.com/repos/joedevivo/chatterbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joedevivo/chatterbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joedevivo/chatterbox/teams","hooks_url":"https://api.github.com/repos/joedevivo/chatterbox/hooks","issue_events_url":"https://api.github.com/repos/joedevivo/chatterbox/issues/events{/number}","events_url":"https://api.github.com/repos/joedevivo/chatterbox/events","assignees_url":"https://api.github.com/repos/joedevivo/chatterbox/assignees{/user}","branches_url":"https://api.github.com/repos/joedevivo/chatterbox/branches{/branch}","tags_url":"https://api.github.com/repos/joedevivo/chatterbox/tags","blobs_url":"https://api.github.com/repos/joedevivo/chatterbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joedevivo/chatterbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joedevivo/chatterbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/joedevivo/chatterbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joedevivo/chatterbox/statuses/{sha}","languages_url":"https://api.github.com/repos/joedevivo/chatterbox/languages","stargazers_url":"https://api.github.com/repos/joedevivo/chatterbox/stargazers","contributors_url":"https://api.github.com/repos/joedevivo/chatterbox/contributors","subscribers_url":"https://api.github.com/repos/joedevivo/chatterbox/subscribers","subscription_url":"https://api.github.com/repos/joedevivo/chatterbox/subscription","commits_url":"https://api.github.com/repos/joedevivo/chatterbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/joedevivo/chatterbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/joedevivo/chatterbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/joedevivo/chatterbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/joedevivo/chatterbox/contents/{+path}","compare_url":"https://api.github.com/repos/joedevivo/chatterbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joedevivo/chatterbox/merges","archive_url":"https://api.github.com/repos/joedevivo/chatterbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joedevivo/chatterbox/downloads","issues_url":"https://api.github.com/repos/joedevivo/chatterbox/issues{/number}","pulls_url":"https://api.github.com/repos/joedevivo/chatterbox/pulls{/number}","milestones_url":"https://api.github.com/repos/joedevivo/chatterbox/milestones{/number}","notifications_url":"https://api.github.com/repos/joedevivo/chatterbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joedevivo/chatterbox/labels{/name}","releases_url":"https://api.github.com/repos/joedevivo/chatterbox/releases{/id}","deployments_url":"https://api.github.com/repos/joedevivo/chatterbox/deployments","created_at":"2015-04-04T20:00:46Z","updated_at":"2016-04-07T11:08:44Z","pushed_at":"2016-04-07T21:14:45Z","git_url":"git://github.com/joedevivo/chatterbox.git","ssh_url":"git@github.com:joedevivo/chatterbox.git","clone_url":"https://github.com/joedevivo/chatterbox.git","svn_url":"https://github.com/joedevivo/chatterbox","homepage":"","size":3221,"stargazers_count":62,"watchers_count":62,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":12,"forks":11,"open_issues":12,"watchers":62,"default_branch":"master"}},"base":{"label":"joedevivo:master","ref":"master","sha":"ab376a04cf46954bda0c330c567d2328478cfacc","user":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"repo":{"id":33418317,"name":"chatterbox","full_name":"joedevivo/chatterbox","owner":{"login":"joedevivo","id":55951,"avatar_url":"https://avatars.githubusercontent.com/u/55951?v=3","gravatar_id":"","url":"https://api.github.com/users/joedevivo","html_url":"https://github.com/joedevivo","followers_url":"https://api.github.com/users/joedevivo/followers","following_url":"https://api.github.com/users/joedevivo/following{/other_user}","gists_url":"https://api.github.com/users/joedevivo/gists{/gist_id}","starred_url":"https://api.github.com/users/joedevivo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedevivo/subscriptions","organizations_url":"https://api.github.com/users/joedevivo/orgs","repos_url":"https://api.github.com/users/joedevivo/repos","events_url":"https://api.github.com/users/joedevivo/events{/privacy}","received_events_url":"https://api.github.com/users/joedevivo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joedevivo/chatterbox","description":"HTTP/2 Server for Erlang. Boy, that guy was a real chatterbox waddn't he?  I didn't think he was ever going to stop with the story.","fork":false,"url":"https://api.github.com/repos/joedevivo/chatterbox","forks_url":"https://api.github.com/repos/joedevivo/chatterbox/forks","keys_url":"https://api.github.com/repos/joedevivo/chatterbox/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joedevivo/chatterbox/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joedevivo/chatterbox/teams","hooks_url":"https://api.github.com/repos/joedevivo/chatterbox/hooks","issue_events_url":"https://api.github.com/repos/joedevivo/chatterbox/issues/events{/number}","events_url":"https://api.github.com/repos/joedevivo/chatterbox/events","assignees_url":"https://api.github.com/repos/joedevivo/chatterbox/assignees{/user}","branches_url":"https://api.github.com/repos/joedevivo/chatterbox/branches{/branch}","tags_url":"https://api.github.com/repos/joedevivo/chatterbox/tags","blobs_url":"https://api.github.com/repos/joedevivo/chatterbox/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joedevivo/chatterbox/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joedevivo/chatterbox/git/refs{/sha}","trees_url":"https://api.github.com/repos/joedevivo/chatterbox/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joedevivo/chatterbox/statuses/{sha}","languages_url":"https://api.github.com/repos/joedevivo/chatterbox/languages","stargazers_url":"https://api.github.com/repos/joedevivo/chatterbox/stargazers","contributors_url":"https://api.github.com/repos/joedevivo/chatterbox/contributors","subscribers_url":"https://api.github.com/repos/joedevivo/chatterbox/subscribers","subscription_url":"https://api.github.com/repos/joedevivo/chatterbox/subscription","commits_url":"https://api.github.com/repos/joedevivo/chatterbox/commits{/sha}","git_commits_url":"https://api.github.com/repos/joedevivo/chatterbox/git/commits{/sha}","comments_url":"https://api.github.com/repos/joedevivo/chatterbox/comments{/number}","issue_comment_url":"https://api.github.com/repos/joedevivo/chatterbox/issues/comments{/number}","contents_url":"https://api.github.com/repos/joedevivo/chatterbox/contents/{+path}","compare_url":"https://api.github.com/repos/joedevivo/chatterbox/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joedevivo/chatterbox/merges","archive_url":"https://api.github.com/repos/joedevivo/chatterbox/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joedevivo/chatterbox/downloads","issues_url":"https://api.github.com/repos/joedevivo/chatterbox/issues{/number}","pulls_url":"https://api.github.com/repos/joedevivo/chatterbox/pulls{/number}","milestones_url":"https://api.github.com/repos/joedevivo/chatterbox/milestones{/number}","notifications_url":"https://api.github.com/repos/joedevivo/chatterbox/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joedevivo/chatterbox/labels{/name}","releases_url":"https://api.github.com/repos/joedevivo/chatterbox/releases{/id}","deployments_url":"https://api.github.com/repos/joedevivo/chatterbox/deployments","created_at":"2015-04-04T20:00:46Z","updated_at":"2016-04-07T11:08:44Z","pushed_at":"2016-04-07T21:14:45Z","git_url":"git://github.com/joedevivo/chatterbox.git","ssh_url":"git@github.com:joedevivo/chatterbox.git","clone_url":"https://github.com/joedevivo/chatterbox.git","svn_url":"https://github.com/joedevivo/chatterbox","homepage":"","size":3221,"stargazers_count":62,"watchers_count":62,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":12,"forks":11,"open_issues":12,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36"},"html":{"href":"https://github.com/joedevivo/chatterbox/pull/36"},"issue":{"href":"https://api.github.com/repos/joedevivo/chatterbox/issues/36"},"comments":{"href":"https://api.github.com/repos/joedevivo/chatterbox/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/joedevivo/chatterbox/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/joedevivo/chatterbox/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/joedevivo/chatterbox/statuses/35b82e235d8770ef11741647cc7a5cd62db6b515"}}}}