{"action":"created","issue":{"url":"https://api.github.com/repos/rack/rack/issues/787","labels_url":"https://api.github.com/repos/rack/rack/issues/787/labels{/name}","comments_url":"https://api.github.com/repos/rack/rack/issues/787/comments","events_url":"https://api.github.com/repos/rack/rack/issues/787/events","html_url":"https://github.com/rack/rack/issues/787","id":55015448,"number":787,"title":"Statuses with no entity body inconsistencies","user":{"login":"jodosha","id":5089,"avatar_url":"https://avatars.githubusercontent.com/u/5089?v=3","gravatar_id":"","url":"https://api.github.com/users/jodosha","html_url":"https://github.com/jodosha","followers_url":"https://api.github.com/users/jodosha/followers","following_url":"https://api.github.com/users/jodosha/following{/other_user}","gists_url":"https://api.github.com/users/jodosha/gists{/gist_id}","starred_url":"https://api.github.com/users/jodosha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jodosha/subscriptions","organizations_url":"https://api.github.com/users/jodosha/orgs","repos_url":"https://api.github.com/users/jodosha/repos","events_url":"https://api.github.com/users/jodosha/events{/privacy}","received_events_url":"https://api.github.com/users/jodosha/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-21T13:02:55Z","updated_at":"2015-01-21T13:19:41Z","closed_at":null,"body":"Hi all,\r\n\r\nI've noticed that `Rack::Lint` [complains](https://github.com/rack/rack/blob/master/lib/rack/lint.rb#L659) if `Content-Type` or `Content-Length` entity headers are set when the status is: `1xx`, `204`, `205` or `304`.\r\n\r\nThose statuses above are defined in a [constant](https://github.com/rack/rack/blob/8d21788798b521b97beb10047ebf593ddc0aaed2/lib/rack/utils.rb#L641) named `STATUS_WITH_NO_ENTITY_BODY`. It regulates other Rack features, such as: chunked and deflated responses etc.\r\n\r\n### Statuses without entity body\r\n\r\nQuoting the RFC 2016, [Section 4](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html):\r\n\r\n> All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a message-body. All other responses do include a message-body, although it MAY be of zero length.\r\n\r\nRack also includes `205` because:\r\n\r\n> 205 Reset Content\r\n> [...] The response MUST NOT include an entity.\r\n\r\nUntil know we know for sure that response body isn't allowed for those HTTP statuses.\r\n\r\n### Should headers be allowed?\r\n\r\nLooking closely at `204` definition:\r\n\r\n> The response MAY include new or updated metainformation in the form of\r\n   entity-headers, which if present SHOULD be associated with the\r\n   requested variant.\r\n\r\nIt looks like entity-headers are allowed. What are those?\r\n\r\n> 7.1 Entity Header Fields\r\n\r\n```\r\nentity-header  = Allow                    ; Section 14.7\r\n                      | Content-Encoding         ; Section 14.11\r\n                      | Content-Language         ; Section 14.12\r\n                      | Content-Length           ; Section 14.13\r\n                      | Content-Location         ; Section 14.14\r\n                      | Content-MD5              ; Section 14.15\r\n                      | Content-Range            ; Section 14.16\r\n                      | Content-Type             ; Section 14.17\r\n                      | Expires                  ; Section 14.21\r\n                      | Last-Modified            ; Section 14.29\r\n                      | extension-header\r\n```\r\n\r\nThe list above enlist both `Content-Length` and `Content-Type` as allowed headers.\r\n\r\nMy questions are:\r\n\r\n  * Is Rack wrong? Or am I miss something?\r\n  * Should headers like `Set-Cookie` be blocked by `Rack::Lint`?\r\n\r\nIf needed I can craft a PR to fix those issues."},"comment":{"url":"https://api.github.com/repos/rack/rack/issues/comments/70834952","html_url":"https://github.com/rack/rack/issues/787#issuecomment-70834952","issue_url":"https://api.github.com/repos/rack/rack/issues/787","id":70834952,"user":{"login":"zavan","id":1722965,"avatar_url":"https://avatars.githubusercontent.com/u/1722965?v=3","gravatar_id":"","url":"https://api.github.com/users/zavan","html_url":"https://github.com/zavan","followers_url":"https://api.github.com/users/zavan/followers","following_url":"https://api.github.com/users/zavan/following{/other_user}","gists_url":"https://api.github.com/users/zavan/gists{/gist_id}","starred_url":"https://api.github.com/users/zavan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zavan/subscriptions","organizations_url":"https://api.github.com/users/zavan/orgs","repos_url":"https://api.github.com/users/zavan/repos","events_url":"https://api.github.com/users/zavan/events{/privacy}","received_events_url":"https://api.github.com/users/zavan/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T13:19:41Z","updated_at":"2015-01-21T13:19:41Z","body":"I'm not sure about that, `Rack::Lint`'s header comment says:\r\n>\r\n  # Rack::Lint validates your application and the requests and\r\n  # responses **according to the Rack spec**.\r\n\r\nThe Rack spec, not any RFC...\r\n\r\nAnd the Rack spec says:\r\n>\r\n  The Content-Type\r\n  There must not be a Content-Type, when the Status is 1xx, 204, 205 or 304.\r\n>\r\n  The Content-Length\r\n  There must not be a Content-Length header when the Status is 1xx, 204, 205 or 304.\r\n\r\n(http://www.rubydoc.info/github/rack/rack/file/SPEC)\r\n\r\nSo I think, first of all, if Rack wants to be fully RFC 2016 compliant, its specs must be changed, and `Rack::Lint` should follow those changes.\r\n\r\nPS.: Damn. Your issues/PRs are always so well written.\r\n"}}