Class | Mongrel::HttpRequest
In: | lib/mongrel/http_request.rb
Parent: | Object

When a handler is found for a registered URI then this class is constructed and passed to your HttpHandler::process method. You should assume that one handler processes all requests. Included in the HttpRequest is a HttpRequest.params Hash that matches common CGI params, and a HttpRequest.body which is a string containing the request body (raw for now).

The HttpRequest.initialize method will convert any request that is larger than Const::MAX_BODY into a Tempfile and use that as the body. Otherwise it uses a StringIO object. To be safe, you should assume it works like a file.

The HttpHandler.request_notify system is implemented by having HttpRequest call HttpHandler.request_begins, HttpHandler.request_progress, HttpHandler.process during the IO processing. This adds a small amount of overhead but lets you implement finer controlled handlers and filters.

### Methods

escape new query_parse read_body read_socket unescape

### Attributes

body | [R] |
params | [R] |

### Public Class methods

escape(s)

Performs URI escaping so that you can construct proper query strings faster. Use this rather than the cgi.rb version since it‘s faster. (Stolen from Camping).

new(params, socket, dispatchers)

You don‘t really call this. It‘s made for you. Main thing it does is hook up the params, and store any remaining body data into the HttpRequest.body attribute.

query_parse(qs, d = '&;')

Parses a query string by breaking it up at the ’&’ and ’;’ characters. You can also use this to parse cookies by changing the characters used in the second parameter (which defaults to ’&;’.

unescape(s)

Unescapes a URI escaped string. (Stolen from Camping).

### Public Instance methods

read_body(remain, total)

Does the heavy lifting of properly reading the larger body requests in small chunks. It expects @body to be an IO object, @socket to be valid, and will set @body = nil if the request fails. It also expects any initial part of the body that has been read to be in the @body already.

read_socket(len)

[Validate]