Make ActionController#head pass rack-link #6148

Merged
merged 2 commits into from May 4, 2012

Projects

None yet

3 participants

@ahawkins

This commit makes head responses pass rack-lint. I came across this bug while implementing HTTP caching in our application. According to rack-lint the content-type header must not be present for 1xx, 204, 205, and 304. I was getting weird 500s in our app because responses were blowing up in rack-lint. This commit fixes that. All the other tests pass.

@jonleighton jonleighton merged commit 8edd21c into rails:master May 4, 2012
@whistlerbrk

@twinturbo I commented in #3436 but I'm also wondering why rack-lint has this requirement. From RFC2616:

14.17 Content-Type

The Content-Type entity-header field indicates the media type of the entity-body sent to the recipient or,
in the case of the HEAD method, the media type that would have been sent had the request been a GET.

I'm not sure why rack-lint has this requirement

@whistlerbrk

rack-link references RFC3875 which specifies:

6.3.1. Content-Type

The Content-Type response field sets the Internet Media Type [6] of
the entity body.

  Content-Type = "Content-Type:" media-type NL

If an entity body is returned, the script MUST supply a Content-Type
field in the response. If it fails to do so, the server SHOULD NOT
attempt to determine the correct content type. The value SHOULD be
sent unmodified to the client, except for any charset parameter
changes.

If I'm reading this correctly the issue is with rack-lint.

L472 of https://github.com/rack/rack/blob/master/lib/rack/lint.rb
Rack::Utils::STATUS_WITH_NO_ENTITY_BODY

I'm going to open an issue in that project...

@ahawkins

@whistlerbrk

If an entity body is returned

That's the key. Those codes should have no body.

@whistlerbrk

@twinturbo Aha! I see it now. My reading of "If it fails to do so" was incorrect. Sorry for the noise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment