Mime type corrections #367

Merged
merged 1 commit into from Dec 30, 2012

Conversation

Projects
None yet
3 participants
Owner

raggi commented Mar 17, 2012

  • HTTP 1.0 and 1.1 do not have MUST for Content-Type requirements, they have "should" (not SHOULD).
  • They also have text describing how clients should handle this header being missing.
  • Whilst it might be a "good idea" to auto set this, it's actually problematic elsewhere.

Opened pull request for discussion.

@chneukirchen @rkh @rtomayko @wycats @tenderlove please weigh in.

If I don't get responses by 1.5, I will merge this in there.

  • I'm also considering changing the default mime to nil in Rack::Mime, thoughts on that?
Owner

raggi commented Mar 17, 2012

References #316 and #366.

Owner

chneukirchen commented Mar 17, 2012

If its not a SHOULD, dont write SHOULD.

And I'd prefer text/html to stay the default for Rack::Response.

Owner

raggi commented Mar 17, 2012

@chneukirchen not sure what your first sentence means.

WRT Rack::Response defaults - cannot happen if we allow for no Content-Type, as it's preventing that from being testable through MockResponse. In essence, it's not "what the application intends".

I suspect you're thinking about ease of use. I think some of the API changes in 2.0 would be more appropriate for ease of use than to enforce things that are potentially incorrect. At the end of the day, our primary use cases are Frameworks and Server authors, not folks "tinkering" with basic apps in lambdas. The latter can be better serviced, but I don't think that should be the concern of the core library / primary APIs.

Example:

run lambda { |env| Rack::Response.html("<h1>ohai</h1>") }

Rather than making Rack::Response.new difficult to use for framework<->server interconnects in certain cases.

Owner

chneukirchen commented Mar 17, 2012

You said its "should" not "SHOULD" but the comment in lint.rb says "SHOULD".

(And then, Rack::Response never was made to be used by frameworks, but I guess that's the way it is now.)

Owner

raggi commented Mar 17, 2012

@chneukirchen lint.rb is wrong. and should is not MUST.

Owner

raggi commented Mar 17, 2012

Correction. 1.1 has SHOULD.

Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type
header field defining the media type of that body. If and only if the media type
is not given by a Content-Type field, the recipient MAY attempt to guess the
media type via inspection of its content and/or the name extension(s) of the URI
used to identify the resource. If the media type remains unknown, the recipient
SHOULD treat it as type "application/octet-stream".

Correct some of the mime type issues. References #316 and #366.
HTTP 1.0 and 1.1 do not have MUST for Content-Type requirements, they have "should" (not SHOULD). They also have text describing how clients should handle this header being missing.
Owner

raggi commented Dec 30, 2012

Just rebased this ready for merge.

raggi added a commit that referenced this pull request Dec 30, 2012

@raggi raggi merged commit c23edf4 into master Dec 30, 2012

1 check passed

default The Travis build passed
Details

@raggi raggi deleted the mime_type branch Dec 30, 2012

Member

rkh commented on lib/rack/response.rb in 3623d04 Jan 29, 2013

@header = Utils::HeaderHash.new(header)?

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