{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/37769678","id":37769678,"diff_hunk":"@@ -0,0 +1,174 @@\n+/*\n+ * Copyright 2015 The Netty Project\n+ *\n+ * The Netty Project licenses this file to you under the Apache License,\n+ * version 2.0 (the \"License\"); you may not use this file except in compliance\n+ * with the License. You may obtain a copy of the License at:\n+ *\n+ *   http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package io.netty.handler.codec.http2;\n+\n+import static io.netty.util.internal.ObjectUtil.checkNotNull;\n+\n+import io.netty.buffer.ByteBuf;\n+import io.netty.buffer.ByteBufHolder;\n+import io.netty.buffer.Unpooled;\n+import io.netty.util.IllegalReferenceCountException;\n+\n+/**\n+ * The default {@link Http2DataFrame} implementation.\n+ */\n+public class DefaultHttp2DataFrame extends AbstractHttp2StreamFrame implements Http2DataFrame {\n+    private final ByteBuf content;\n+    private final boolean endStream;\n+    private final int padding;\n+\n+    /**\n+     * Equivalent to {@code new DefaultHttp2DataFrame(content, false)}.\n+     *\n+     * @param content non-{@code null} payload\n+     */\n+    public DefaultHttp2DataFrame(ByteBuf content) {\n+        this(content, false);\n+    }\n+\n+    /**\n+     * Equivalent to {@code new DefaultHttp2DataFrame(Unpooled.EMPTY_BUFFER, endStream)}.\n+     *\n+     * @param endStream whether this data should terminate the stream\n+     */\n+    public DefaultHttp2DataFrame(boolean endStream) {\n+        this(Unpooled.EMPTY_BUFFER, endStream);\n+    }\n+\n+    /**\n+     * Equivalent to {@code new DefaultHttp2DataFrame(content, endStream, 0)}.\n+     *\n+     * @param content non-{@code null} payload\n+     * @param endStream whether this data should terminate the stream\n+     */\n+    public DefaultHttp2DataFrame(ByteBuf content, boolean endStream) {\n+        this(content, endStream, 0);\n+    }\n+\n+    /**\n+     * Construct a new data message.\n+     *\n+     * @param content non-{@code null} payload\n+     * @param endStream whether this data should terminate the stream\n+     * @param padding additional bytes that should be added to obscure the true content size\n+     */\n+    public DefaultHttp2DataFrame(ByteBuf content, boolean endStream, int padding) {\n+        this.content = checkNotNull(content, \"content\");\n+        this.endStream = endStream;\n+        if (padding < 0 || padding > Http2CodecUtil.MAX_UNSIGNED_BYTE) {\n+            throw new IllegalArgumentException(\"padding must be non-negative and less than 256\");\n+        }\n+        this.padding = padding;\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame setStream(Object stream) {\n+      super.setStream(stream);\n+      return this;\n+    }\n+\n+    @Override\n+    public boolean endStream() {\n+        return endStream;\n+    }\n+\n+    @Override\n+    public int padding() {\n+        return padding;\n+    }\n+\n+    @Override\n+    public ByteBuf content() {\n+        if (content.refCnt() <= 0) {\n+            throw new IllegalReferenceCountException(content.refCnt());\n+        }\n+        return content;\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame copy() {\n+        return new DefaultHttp2DataFrame(content().copy(), endStream, padding);\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame duplicate() {\n+        return new DefaultHttp2DataFrame(content().duplicate(), endStream, padding);\n+    }\n+\n+    @Override\n+    public int refCnt() {\n+        return content.refCnt();\n+    }\n+\n+    @Override\n+    public boolean release() {\n+        return content.release();\n+    }\n+\n+    @Override\n+    public boolean release(int decrement) {\n+        return content.release(decrement);\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame retain() {\n+        content.retain();\n+        return this;\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame retain(int increment) {\n+        content.retain(increment);\n+        return this;\n+    }\n+\n+    @Override\n+    public String toString() {\n+        return \"DefaultHttp2DataFrame(stream=\" + stream() + \",content=\" + content\n+            + \",endStream=\" + endStream + \",padding=\" + padding + \")\";\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame touch() {\n+        content.touch();\n+        return this;\n+    }\n+\n+    @Override\n+    public DefaultHttp2DataFrame touch(Object hint) {\n+        content.touch(hint);\n+        return this;\n+    }\n+\n+    @Override\n+    public boolean equals(Object o) {\n+        if (!(o instanceof DefaultHttp2DataFrame)) {\n+            return false;\n+        }\n+        DefaultHttp2DataFrame other = (DefaultHttp2DataFrame) o;\n+        return super.equals(other) && content.equals(other.content())\n+            && endStream == other.endStream && padding == other.padding;\n+    }\n+\n+    @Override\n+    public int hashCode() {\n+        int hash = super.hashCode();\n+        hash = hash * 31 + content.hashCode();\n+        hash = hash * 31 + (endStream ? 0 : 1);","path":"codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2DataFrame.java","position":169,"original_position":170,"commit_id":"3908943ac3e7950085a056aa3cc5e037eb38f570","original_commit_id":"b6d3f263157cb0ae4422696045fe25f1ebf86660","user":{"login":"Scottmitch","id":7562868,"avatar_url":"https://avatars.githubusercontent.com/u/7562868?v=3","gravatar_id":"","url":"https://api.github.com/users/Scottmitch","html_url":"https://github.com/Scottmitch","followers_url":"https://api.github.com/users/Scottmitch/followers","following_url":"https://api.github.com/users/Scottmitch/following{/other_user}","gists_url":"https://api.github.com/users/Scottmitch/gists{/gist_id}","starred_url":"https://api.github.com/users/Scottmitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Scottmitch/subscriptions","organizations_url":"https://api.github.com/users/Scottmitch/orgs","repos_url":"https://api.github.com/users/Scottmitch/repos","events_url":"https://api.github.com/users/Scottmitch/events{/privacy}","received_events_url":"https://api.github.com/users/Scottmitch/received_events","type":"User","site_admin":false},"body":"Good point. Disregard.","created_at":"2015-08-24T16:17:10Z","updated_at":"2015-08-24T16:17:10Z","html_url":"https://github.com/netty/netty/pull/3666#discussion_r37769678","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/3666","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/37769678"},"html":{"href":"https://github.com/netty/netty/pull/3666#discussion_r37769678"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/3666"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/3666","id":33687918,"html_url":"https://github.com/netty/netty/pull/3666","diff_url":"https://github.com/netty/netty/pull/3666.diff","patch_url":"https://github.com/netty/netty/pull/3666.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/3666","number":3666,"state":"open","locked":false,"title":"Map HTTP/2 Streams to Channels","user":{"login":"ejona86","id":2811396,"avatar_url":"https://avatars.githubusercontent.com/u/2811396?v=3","gravatar_id":"","url":"https://api.github.com/users/ejona86","html_url":"https://github.com/ejona86","followers_url":"https://api.github.com/users/ejona86/followers","following_url":"https://api.github.com/users/ejona86/following{/other_user}","gists_url":"https://api.github.com/users/ejona86/gists{/gist_id}","starred_url":"https://api.github.com/users/ejona86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejona86/subscriptions","organizations_url":"https://api.github.com/users/ejona86/orgs","repos_url":"https://api.github.com/users/ejona86/repos","events_url":"https://api.github.com/users/ejona86/events{/privacy}","received_events_url":"https://api.github.com/users/ejona86/received_events","type":"User","site_admin":false},"body":"This allows using handlers for Streams in normal Netty-style.\r\n\r\nDetails can be discussed in this PR, but I do expect it to be thrown away or heavily-tweaked. The larger discussion should probably take place in an issue that will be created shortly.","created_at":"2015-04-20T17:34:50Z","updated_at":"2015-08-24T16:17:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5ea9a65a286e1d944f7944b230ebebeb8e35282f","assignee":null,"milestone":{"url":"https://api.github.com/repos/netty/netty/milestones/117","html_url":"https://github.com/netty/netty/milestones/4.1.0.Beta6","labels_url":"https://api.github.com/repos/netty/netty/milestones/117/labels","id":1100817,"number":117,"title":"4.1.0.Beta6","description":"","creator":{"login":"normanmaurer","id":439362,"avatar_url":"https://avatars.githubusercontent.com/u/439362?v=3","gravatar_id":"","url":"https://api.github.com/users/normanmaurer","html_url":"https://github.com/normanmaurer","followers_url":"https://api.github.com/users/normanmaurer/followers","following_url":"https://api.github.com/users/normanmaurer/following{/other_user}","gists_url":"https://api.github.com/users/normanmaurer/gists{/gist_id}","starred_url":"https://api.github.com/users/normanmaurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/normanmaurer/subscriptions","organizations_url":"https://api.github.com/users/normanmaurer/orgs","repos_url":"https://api.github.com/users/normanmaurer/repos","events_url":"https://api.github.com/users/normanmaurer/events{/privacy}","received_events_url":"https://api.github.com/users/normanmaurer/received_events","type":"User","site_admin":false},"open_issues":68,"closed_issues":84,"state":"open","created_at":"2015-05-07T19:29:09Z","updated_at":"2015-08-21T18:45:11Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/netty/netty/pulls/3666/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/3666/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/3666/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/3908943ac3e7950085a056aa3cc5e037eb38f570","head":{"label":"ejona86:http2-stream-as-channel","ref":"http2-stream-as-channel","sha":"3908943ac3e7950085a056aa3cc5e037eb38f570","user":{"login":"ejona86","id":2811396,"avatar_url":"https://avatars.githubusercontent.com/u/2811396?v=3","gravatar_id":"","url":"https://api.github.com/users/ejona86","html_url":"https://github.com/ejona86","followers_url":"https://api.github.com/users/ejona86/followers","following_url":"https://api.github.com/users/ejona86/following{/other_user}","gists_url":"https://api.github.com/users/ejona86/gists{/gist_id}","starred_url":"https://api.github.com/users/ejona86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejona86/subscriptions","organizations_url":"https://api.github.com/users/ejona86/orgs","repos_url":"https://api.github.com/users/ejona86/repos","events_url":"https://api.github.com/users/ejona86/events{/privacy}","received_events_url":"https://api.github.com/users/ejona86/received_events","type":"User","site_admin":false},"repo":{"id":32953128,"name":"netty","full_name":"ejona86/netty","owner":{"login":"ejona86","id":2811396,"avatar_url":"https://avatars.githubusercontent.com/u/2811396?v=3","gravatar_id":"","url":"https://api.github.com/users/ejona86","html_url":"https://github.com/ejona86","followers_url":"https://api.github.com/users/ejona86/followers","following_url":"https://api.github.com/users/ejona86/following{/other_user}","gists_url":"https://api.github.com/users/ejona86/gists{/gist_id}","starred_url":"https://api.github.com/users/ejona86/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejona86/subscriptions","organizations_url":"https://api.github.com/users/ejona86/orgs","repos_url":"https://api.github.com/users/ejona86/repos","events_url":"https://api.github.com/users/ejona86/events{/privacy}","received_events_url":"https://api.github.com/users/ejona86/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ejona86/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/ejona86/netty","forks_url":"https://api.github.com/repos/ejona86/netty/forks","keys_url":"https://api.github.com/repos/ejona86/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ejona86/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ejona86/netty/teams","hooks_url":"https://api.github.com/repos/ejona86/netty/hooks","issue_events_url":"https://api.github.com/repos/ejona86/netty/issues/events{/number}","events_url":"https://api.github.com/repos/ejona86/netty/events","assignees_url":"https://api.github.com/repos/ejona86/netty/assignees{/user}","branches_url":"https://api.github.com/repos/ejona86/netty/branches{/branch}","tags_url":"https://api.github.com/repos/ejona86/netty/tags","blobs_url":"https://api.github.com/repos/ejona86/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ejona86/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ejona86/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/ejona86/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ejona86/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/ejona86/netty/languages","stargazers_url":"https://api.github.com/repos/ejona86/netty/stargazers","contributors_url":"https://api.github.com/repos/ejona86/netty/contributors","subscribers_url":"https://api.github.com/repos/ejona86/netty/subscribers","subscription_url":"https://api.github.com/repos/ejona86/netty/subscription","commits_url":"https://api.github.com/repos/ejona86/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/ejona86/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/ejona86/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/ejona86/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/ejona86/netty/contents/{+path}","compare_url":"https://api.github.com/repos/ejona86/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ejona86/netty/merges","archive_url":"https://api.github.com/repos/ejona86/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ejona86/netty/downloads","issues_url":"https://api.github.com/repos/ejona86/netty/issues{/number}","pulls_url":"https://api.github.com/repos/ejona86/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/ejona86/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/ejona86/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ejona86/netty/labels{/name}","releases_url":"https://api.github.com/repos/ejona86/netty/releases{/id}","created_at":"2015-03-26T21:34:39Z","updated_at":"2015-05-07T20:10:29Z","pushed_at":"2015-08-22T21:08:10Z","git_url":"git://github.com/ejona86/netty.git","ssh_url":"git@github.com:ejona86/netty.git","clone_url":"https://github.com/ejona86/netty.git","svn_url":"https://github.com/ejona86/netty","homepage":"http://netty.io/","size":44002,"stargazers_count":1,"watchers_count":1,"language":"Java","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":1,"default_branch":"master"}},"base":{"label":"netty:master","ref":"master","sha":"0d8ce23c83ad7fa67245c721ba4d47437458ddfc","user":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","created_at":"2010-11-09T09:22:21Z","updated_at":"2015-08-24T15:40:48Z","pushed_at":"2015-08-24T03:47:21Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":129619,"stargazers_count":5099,"watchers_count":5099,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2583,"mirror_url":null,"open_issues_count":318,"forks":2583,"open_issues":318,"watchers":5099,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/3666"},"html":{"href":"https://github.com/netty/netty/pull/3666"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/3666"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/3666/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/3666/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/3666/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/3908943ac3e7950085a056aa3cc5e037eb38f570"}}}}