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

Handle mulipart requests with no part names #816

Merged
merged 1 commit into from
Mar 5, 2015

Conversation

english
Copy link
Contributor

@english english commented Mar 3, 2015

Currently, a multipart request with no Content-Disposition or Content-ID headers for each part results in a NoMethodError: undefined method 'force_encoding' for nil:NilClass error at lib/rack/multipart/parser.rb:196.

The following is a minimal request that reproduces the error:

POST /foo HTTP/1.1
Content-Type: multipart/related; boundary=AaB03x

--AaB03x

some text
--AaB03x--

Neither Content-Disposition nor Content-ID are required headers for multipart request parts: rfc1341.

The problem is that the name for the part isn't being assigned. I've chosen to assign it to the Content-Type of the part (falling back to text/plain as per rfc1341), and then store this in param as a list. This is the same strategy used in https://github.com/whostolebenfrog/compojure-multipart.

Previously, Rack would assume there would be either a Content-Disposition or Content-ID
header for multipart request parts. This is not required in [rfc1341][0].

Now, Rack will use the Content-Type (falling back to text/plain) for the part name,
storing parameters in an array, keyed off the content type.

[0]: http://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
tenderlove added a commit that referenced this pull request Mar 5, 2015
Handle mulipart requests with no part names
@tenderlove tenderlove merged commit b510afd into rack:master Mar 5, 2015
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.

2 participants