{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/31519214","id":31519214,"diff_hunk":"@@ -20,83 +20,128 @@\n import io.netty.handler.codec.compression.ZlibWrapper;\n import io.netty.util.internal.StringUtil;\n \n+import java.util.regex.Pattern;\n+\n /**\n  * Compresses an {@link HttpMessage} and an {@link HttpContent} in {@code gzip} or\n- * {@code deflate} encoding while respecting the {@code \"Accept-Encoding\"} header.\n- * If there is no matching encoding, no compression is done.  For more\n- * information on how this handler modifies the message, please refer to\n- * {@link HttpContentEncoder}.\n+ * {@code deflate} encoding while respecting the {@code \"Accept-Encoding\"} header. If there is no matching encoding,\n+ * no compression is done.\n+ *\n+ * Note that only a {@link FullHttpResponse} or a response with {@code \"Transfer-Encoding: chunked\"}\n+ * will be compressed. Also the {@code \"Content-Length\"} and {@code \"Content-Type\"} are checked against\n+ * the given <tt>minCompressableContentLength</tt> and <tt>compressableContentTypes</tt> to determined if\n+ * a compression would be effective at all.\n+ *\n+ * For more information on how this handler modifies the message, please refer to {@link HttpContentEncoder}.\n  */\n public class HttpContentCompressor extends HttpContentEncoder {\n \n+    public static final int DEFAULT_COMPRESSION_LEVEL = 6;\n+    public static final int DEFAULT_WINDOW_BITS = 15;\n+    public static final int DEFAULT_MEM_LEVEL = 8;\n+    public static final int DEFAULT_MIN_COMPRESSABLE_CONTENT_LENGTH = 1024;\n+    public static final Pattern DEFAULT_COMPRESSABLE_CONTENT_TYPES = Pattern.compile(\"(text/.*|application/json.*)\");","path":"codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java","position":28,"original_position":28,"commit_id":"cbd96bfa093ab49b5c5f0aa1e1593915fb42235b","original_commit_id":"cbd96bfa093ab49b5c5f0aa1e1593915fb42235b","user":{"login":"andyHa","id":875799,"avatar_url":"https://avatars.githubusercontent.com/u/875799?v=3","gravatar_id":"","url":"https://api.github.com/users/andyHa","html_url":"https://github.com/andyHa","followers_url":"https://api.github.com/users/andyHa/followers","following_url":"https://api.github.com/users/andyHa/following{/other_user}","gists_url":"https://api.github.com/users/andyHa/gists{/gist_id}","starred_url":"https://api.github.com/users/andyHa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyHa/subscriptions","organizations_url":"https://api.github.com/users/andyHa/orgs","repos_url":"https://api.github.com/users/andyHa/repos","events_url":"https://api.github.com/users/andyHa/events{/privacy}","received_events_url":"https://api.github.com/users/andyHa/received_events","type":"User","site_admin":false},"body":"I understand, for this very reason I left the beaking unit test in the PR. I think backward compatibility is the way to go! Shall I update the PR with the logic I proposed earlier? I'd also add / expand the JavaDoc so that a new user of the class is pushed in the right direction. You still could, at some point, then deprecate the old constructor(s). This would show existing users of the class that there is a change and they could figure out which settings to use...","created_at":"2015-06-02T13:00:02Z","updated_at":"2015-06-02T13:00:02Z","html_url":"https://github.com/netty/netty/pull/3847#discussion_r31519214","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/3847","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/31519214"},"html":{"href":"https://github.com/netty/netty/pull/3847#discussion_r31519214"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/3847"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/3847","id":36564255,"html_url":"https://github.com/netty/netty/pull/3847","diff_url":"https://github.com/netty/netty/pull/3847.diff","patch_url":"https://github.com/netty/netty/pull/3847.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/3847","number":3847,"state":"open","locked":false,"title":"Skip http content compression for small or uncompressable content","user":{"login":"andyHa","id":875799,"avatar_url":"https://avatars.githubusercontent.com/u/875799?v=3","gravatar_id":"","url":"https://api.github.com/users/andyHa","html_url":"https://github.com/andyHa","followers_url":"https://api.github.com/users/andyHa/followers","following_url":"https://api.github.com/users/andyHa/following{/other_user}","gists_url":"https://api.github.com/users/andyHa/gists{/gist_id}","starred_url":"https://api.github.com/users/andyHa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyHa/subscriptions","organizations_url":"https://api.github.com/users/andyHa/orgs","repos_url":"https://api.github.com/users/andyHa/repos","events_url":"https://api.github.com/users/andyHa/events{/privacy}","received_events_url":"https://api.github.com/users/andyHa/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nContent compression is not very effective for small results (default y 1024 bytes) or for already compresst content like JPEG images. Also the content compressor must be skipped for certain types of responses (like when sending a DefaultFileRegion). Therefore only FullResponses or chunked responses should be considered for content compression as otherwise an invalid result (Content-Encoding: gzip with uncompressed data) can be created.\r\n\r\nModification:\r\n\r\nIntroduced 2 new parameters for the content compressor: minCompressableContentLength (default: 1024) and compressableContentTypes (default: text/* and application/json) to better control when compression is turned on.\r\nAlso added a filter to only compress FullHttpResponses or ones with Transfer-Encoding: chunked.\r\n\r\nResult:\r\nThen content compressor now skips small or uncompressable results","created_at":"2015-05-30T11:31:28Z","updated_at":"2015-06-02T13:00:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8c6b45bf6f43c4f1f2627b1fad139394df4e9917","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/3847/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/3847/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/3847/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/cbd96bfa093ab49b5c5f0aa1e1593915fb42235b","head":{"label":"andyHa:master","ref":"master","sha":"cbd96bfa093ab49b5c5f0aa1e1593915fb42235b","user":{"login":"andyHa","id":875799,"avatar_url":"https://avatars.githubusercontent.com/u/875799?v=3","gravatar_id":"","url":"https://api.github.com/users/andyHa","html_url":"https://github.com/andyHa","followers_url":"https://api.github.com/users/andyHa/followers","following_url":"https://api.github.com/users/andyHa/following{/other_user}","gists_url":"https://api.github.com/users/andyHa/gists{/gist_id}","starred_url":"https://api.github.com/users/andyHa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyHa/subscriptions","organizations_url":"https://api.github.com/users/andyHa/orgs","repos_url":"https://api.github.com/users/andyHa/repos","events_url":"https://api.github.com/users/andyHa/events{/privacy}","received_events_url":"https://api.github.com/users/andyHa/received_events","type":"User","site_admin":false},"repo":{"id":36505890,"name":"netty","full_name":"andyHa/netty","owner":{"login":"andyHa","id":875799,"avatar_url":"https://avatars.githubusercontent.com/u/875799?v=3","gravatar_id":"","url":"https://api.github.com/users/andyHa","html_url":"https://github.com/andyHa","followers_url":"https://api.github.com/users/andyHa/followers","following_url":"https://api.github.com/users/andyHa/following{/other_user}","gists_url":"https://api.github.com/users/andyHa/gists{/gist_id}","starred_url":"https://api.github.com/users/andyHa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyHa/subscriptions","organizations_url":"https://api.github.com/users/andyHa/orgs","repos_url":"https://api.github.com/users/andyHa/repos","events_url":"https://api.github.com/users/andyHa/events{/privacy}","received_events_url":"https://api.github.com/users/andyHa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andyHa/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/andyHa/netty","forks_url":"https://api.github.com/repos/andyHa/netty/forks","keys_url":"https://api.github.com/repos/andyHa/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andyHa/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andyHa/netty/teams","hooks_url":"https://api.github.com/repos/andyHa/netty/hooks","issue_events_url":"https://api.github.com/repos/andyHa/netty/issues/events{/number}","events_url":"https://api.github.com/repos/andyHa/netty/events","assignees_url":"https://api.github.com/repos/andyHa/netty/assignees{/user}","branches_url":"https://api.github.com/repos/andyHa/netty/branches{/branch}","tags_url":"https://api.github.com/repos/andyHa/netty/tags","blobs_url":"https://api.github.com/repos/andyHa/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andyHa/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andyHa/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/andyHa/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andyHa/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/andyHa/netty/languages","stargazers_url":"https://api.github.com/repos/andyHa/netty/stargazers","contributors_url":"https://api.github.com/repos/andyHa/netty/contributors","subscribers_url":"https://api.github.com/repos/andyHa/netty/subscribers","subscription_url":"https://api.github.com/repos/andyHa/netty/subscription","commits_url":"https://api.github.com/repos/andyHa/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/andyHa/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/andyHa/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/andyHa/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/andyHa/netty/contents/{+path}","compare_url":"https://api.github.com/repos/andyHa/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andyHa/netty/merges","archive_url":"https://api.github.com/repos/andyHa/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andyHa/netty/downloads","issues_url":"https://api.github.com/repos/andyHa/netty/issues{/number}","pulls_url":"https://api.github.com/repos/andyHa/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/andyHa/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/andyHa/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andyHa/netty/labels{/name}","releases_url":"https://api.github.com/repos/andyHa/netty/releases{/id}","created_at":"2015-05-29T13:26:58Z","updated_at":"2015-05-29T13:27:06Z","pushed_at":"2015-05-30T15:02:01Z","git_url":"git://github.com/andyHa/netty.git","ssh_url":"git@github.com:andyHa/netty.git","clone_url":"https://github.com/andyHa/netty.git","svn_url":"https://github.com/andyHa/netty","homepage":"http://netty.io/","size":42880,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"netty:master","ref":"master","sha":"895ceb72a3d8cd30911b8f7887a5df2b7c50d2d0","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-06-02T12:04:40Z","pushed_at":"2015-06-02T11:24:50Z","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":131386,"stargazers_count":4708,"watchers_count":4708,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2320,"mirror_url":null,"open_issues_count":284,"forks":2320,"open_issues":284,"watchers":4708,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/3847"},"html":{"href":"https://github.com/netty/netty/pull/3847"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/3847"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/3847/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/3847/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/3847/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/cbd96bfa093ab49b5c5f0aa1e1593915fb42235b"}}}}