Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parsing of arbitrary media type parameters. #5290

Merged
merged 1 commit into from
Mar 5, 2012

Conversation

steveklabnik
Copy link
Member

Mime types can accept arbitrary parameters. Right now, we only supported the q parameter, this extends them to arbitrary ones.

Here's the grammar: http://www.ietf.org/rfc/rfc2045.txt

This parsing is still not fantastic: the regexp might be made better, since it doesn't ensure that we have both actual quotes. Also, I'm not 100% \w matches up with '<any (US-ASCII) CHAR except SPACE, CTLs, or tspecials>'

Related: #4918 and #4127.

josevalim added a commit that referenced this pull request Mar 5, 2012
Added parsing of arbitrary media type parameters.
@josevalim josevalim merged commit dc80715 into rails:master Mar 5, 2012
@steveklabnik
Copy link
Member Author

Woot! Thank you!

@rkh
Copy link
Contributor

rkh commented Mar 5, 2012

Is there a way to do content negotiation with this? Say, have the version as parameter?

@steveklabnik
Copy link
Member Author

Yes. The accept header allows you to include 'extension parameters':

accept-extension = ";" token [ "=" ( token | quoted-string ) ]

@rkh
Copy link
Contributor

rkh commented Mar 5, 2012

No, I know that, I meant more along the lines: While you do handle parsing those parameters there, is some API exposed by rack to take this into account, say with respond_with, or do I have to interpret env on my own?

@steveklabnik
Copy link
Member Author

Ahhh. I have no idea, to be honest. This came out of a request for this gem, which is working on this kind of thing. I haven't actually used this for anything yet, this is just the most fundamental change needed. It's quite possible to use it effectively, more things need to be exposed higher up in rack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants