#71 ✓resolved

[PATCH] Parsing non-nested requests

Reported by bahuvrihi | August 11th, 2009 @ 02:56 PM | in 1.1

I have run into situations where I'd like to parse requests in a non-nested fashion. Rack::Request almost lets you do this, but not quite. This commit refactors Rack::Request so that the parsing methods for query strings and multipart data may be overridden.


Query Strings

With the patch, you can parse non-nested query strings by subclassing Request to call Utils.parse_query instead of Utils.parse_nested_query.

Multipart Data

Parsing multipart data in a non-nested fashion requires second patch because parse_multipart parses nested queries and you can't get around that. This commit adds a flag to parse_multipart to allow non-nested parsing.


The flag is a little inelegant, but at least it's backwards compatible. A more elegant solution would be to have two methods: parse_multipart and parse_nested_multipart. However, this solution is problematic because it requires surprising, backwards-incompatible flip in the meaning of parse_multipart.

With both patches a non-multipart request class looks like this:

  class NonMultipartRequest < Request
    def parse_query(qs)

    def parse_multipart(env)
      Utils::Multipart.parse_multipart(env, false)

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket