{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/finagle/pulls/comments/68779631","id":68779631,"diff_hunk":"@@ -0,0 +1,55 @@\n+package com.twitter.finagle.http.filter\n+\n+import com.twitter.finagle.http.{Fields, Request, Response, Status}\n+import com.twitter.finagle._\n+import com.twitter.util.Future\n+\n+/**","path":"finagle-http/src/main/scala/com/twitter/finagle/http/filter/ModifyContentAndHeaderFieldFilter.scala","position":null,"original_position":7,"commit_id":"f0856db8850cd299c34be1730bd397dc989d536b","original_commit_id":"656d289a1e3136df511fb6448725edec893de110","user":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"body":"Sure, I've added the corresponding test! :D","created_at":"2016-06-28T15:25:54Z","updated_at":"2016-06-28T15:25:54Z","html_url":"https://github.com/twitter/finagle/pull/521#discussion_r68779631","pull_request_url":"https://api.github.com/repos/twitter/finagle/pulls/521","_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments/68779631"},"html":{"href":"https://github.com/twitter/finagle/pull/521#discussion_r68779631"},"pull_request":{"href":"https://api.github.com/repos/twitter/finagle/pulls/521"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/finagle/pulls/521","id":75206132,"html_url":"https://github.com/twitter/finagle/pull/521","diff_url":"https://github.com/twitter/finagle/pull/521.diff","patch_url":"https://github.com/twitter/finagle/pull/521.patch","issue_url":"https://api.github.com/repos/twitter/finagle/issues/521","number":521,"state":"open","locked":false,"title":"finagle-http: Fix body and header in 204 and 304","user":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"body":"Problem\r\n\r\nWe currently have two problems. Firstly, as described in [RFC2616](https://tools.ietf.org/html/rfc2616) and\r\n[RFC7231](https://tools.ietf.org/html/rfc7231), 204 and 304 responses must not contain a message-body. This\r\nrequirement was not enforced in finagle, i.e., a message-body can be\r\nadded. Moreover, a Content-Length header field can be added to these responses,\r\nwhich is not allowed as mentioned in [RFC7230#section-3.3.2](https://tools.ietf.org/html/rfc7230#section-3.3.2).\r\n\r\nSolution\r\n    \r\nFirst of all, we have to clear a message-body, which we call content in finagle,\r\nif the response status code is either 204 or 304 to satisfy RFC7231. Secondly,\r\nwe need to make sure not to add a Content-Length header field in a 204 response\r\nto follow RFC7230#section-3.3.2. With regard to a 304 response, a server may\r\nsend a Content-Length header as mentioned in the same section. Thus it'd be\r\nbetter for us to allow users to set the field with a value of 0 if they like.\r\nMost importantly, [we make sure that these things are achieved and the new system\r\nis bugwards-compatible by provding a new filter](https://github.com/twitter/finagle/pull/521#issuecomment-228566007).\r\n\r\nResult\r\n\r\nWe follow the specification of RFC with regard to a message-header and\r\nmessage-body except that we have not added some header fields required in a\r\nresponse with status code 304 to satisfy [RFC7232#section-4.1](https://tools.ietf.org/html/rfc7232#section-4.1); Any of the\r\nfollowing header fields must be generated: Cache-Control, Content-Location,\r\nDate, ETag, Expires, and Vary.\r\nAs we achieve this by creating a new filter and set it to [Http.scala](https://github.com/monkey-mas/finagle/blob/finagle-6.35.0/finagle-http/src/main/scala/com/twitter/finagle/Http.scala#L298-L304), users\r\nwho are not willing to make use of the functionality can easily disable it\r\nby removing the filter.","created_at":"2016-06-25T14:39:33Z","updated_at":"2016-06-28T15:25:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e918a318a9ea1a1136dd9ec943836f57e624893","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/twitter/finagle/pulls/521/commits","review_comments_url":"https://api.github.com/repos/twitter/finagle/pulls/521/comments","review_comment_url":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/finagle/issues/521/comments","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/f0856db8850cd299c34be1730bd397dc989d536b","head":{"label":"monkey-mas:fix-body-and-header-in-204-and-304","ref":"fix-body-and-header-in-204-and-304","sha":"f0856db8850cd299c34be1730bd397dc989d536b","user":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"repo":{"id":61439509,"name":"finagle","full_name":"monkey-mas/finagle","owner":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monkey-mas/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":true,"url":"https://api.github.com/repos/monkey-mas/finagle","forks_url":"https://api.github.com/repos/monkey-mas/finagle/forks","keys_url":"https://api.github.com/repos/monkey-mas/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monkey-mas/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monkey-mas/finagle/teams","hooks_url":"https://api.github.com/repos/monkey-mas/finagle/hooks","issue_events_url":"https://api.github.com/repos/monkey-mas/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/monkey-mas/finagle/events","assignees_url":"https://api.github.com/repos/monkey-mas/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/monkey-mas/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/monkey-mas/finagle/tags","blobs_url":"https://api.github.com/repos/monkey-mas/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monkey-mas/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monkey-mas/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/monkey-mas/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monkey-mas/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/monkey-mas/finagle/languages","stargazers_url":"https://api.github.com/repos/monkey-mas/finagle/stargazers","contributors_url":"https://api.github.com/repos/monkey-mas/finagle/contributors","subscribers_url":"https://api.github.com/repos/monkey-mas/finagle/subscribers","subscription_url":"https://api.github.com/repos/monkey-mas/finagle/subscription","commits_url":"https://api.github.com/repos/monkey-mas/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/monkey-mas/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/monkey-mas/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/monkey-mas/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/monkey-mas/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/monkey-mas/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monkey-mas/finagle/merges","archive_url":"https://api.github.com/repos/monkey-mas/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monkey-mas/finagle/downloads","issues_url":"https://api.github.com/repos/monkey-mas/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/monkey-mas/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/monkey-mas/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/monkey-mas/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monkey-mas/finagle/labels{/name}","releases_url":"https://api.github.com/repos/monkey-mas/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/monkey-mas/finagle/deployments","created_at":"2016-06-18T15:22:09Z","updated_at":"2016-06-18T15:22:14Z","pushed_at":"2016-06-28T14:58:04Z","git_url":"git://github.com/monkey-mas/finagle.git","ssh_url":"git@github.com:monkey-mas/finagle.git","clone_url":"https://github.com/monkey-mas/finagle.git","svn_url":"https://github.com/monkey-mas/finagle","homepage":"http://twitter.github.io/finagle","size":39981,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"twitter:develop","ref":"develop","sha":"b98237f28fc7baeaaf37bec027eff62223396513","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":1007362,"name":"finagle","full_name":"twitter/finagle","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/finagle","description":"A fault tolerant, protocol-agnostic RPC system","fork":false,"url":"https://api.github.com/repos/twitter/finagle","forks_url":"https://api.github.com/repos/twitter/finagle/forks","keys_url":"https://api.github.com/repos/twitter/finagle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/finagle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/finagle/teams","hooks_url":"https://api.github.com/repos/twitter/finagle/hooks","issue_events_url":"https://api.github.com/repos/twitter/finagle/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/finagle/events","assignees_url":"https://api.github.com/repos/twitter/finagle/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/finagle/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/finagle/tags","blobs_url":"https://api.github.com/repos/twitter/finagle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/finagle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/finagle/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/finagle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/finagle/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/finagle/languages","stargazers_url":"https://api.github.com/repos/twitter/finagle/stargazers","contributors_url":"https://api.github.com/repos/twitter/finagle/contributors","subscribers_url":"https://api.github.com/repos/twitter/finagle/subscribers","subscription_url":"https://api.github.com/repos/twitter/finagle/subscription","commits_url":"https://api.github.com/repos/twitter/finagle/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/finagle/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/finagle/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/finagle/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/finagle/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/finagle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/finagle/merges","archive_url":"https://api.github.com/repos/twitter/finagle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/finagle/downloads","issues_url":"https://api.github.com/repos/twitter/finagle/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/finagle/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/finagle/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/finagle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/finagle/labels{/name}","releases_url":"https://api.github.com/repos/twitter/finagle/releases{/id}","deployments_url":"https://api.github.com/repos/twitter/finagle/deployments","created_at":"2010-10-19T22:10:09Z","updated_at":"2016-06-28T14:17:15Z","pushed_at":"2016-06-28T14:58:05Z","git_url":"git://github.com/twitter/finagle.git","ssh_url":"git@github.com:twitter/finagle.git","clone_url":"https://github.com/twitter/finagle.git","svn_url":"https://github.com/twitter/finagle","homepage":"http://twitter.github.io/finagle","size":48025,"stargazers_count":4775,"watchers_count":4775,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":905,"mirror_url":null,"open_issues_count":26,"forks":905,"open_issues":26,"watchers":4775,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/finagle/pulls/521"},"html":{"href":"https://github.com/twitter/finagle/pull/521"},"issue":{"href":"https://api.github.com/repos/twitter/finagle/issues/521"},"comments":{"href":"https://api.github.com/repos/twitter/finagle/issues/521/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/finagle/pulls/521/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/finagle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/finagle/pulls/521/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/finagle/statuses/f0856db8850cd299c34be1730bd397dc989d536b"}}}}
{"actor":{"display_login":"monkey-mas"}}