about summary refs log tree commit homepage
path: root/ext
DateCommit message (Collapse)
2009-11-04http: allow headers/trailers to be written byte-wise
This allows clients to trickle headers and trailers. While Unicorn itself does not support slow clients for many reasons, this affects servers that depend on our parser like Rainbows!. This actually does affect Unicorn when handling trailers, but HTTP trailers are very ever rarely used in requests. Fortunately this stupid bug does not seem able to trigger out-of-bounds conditions.
2009-09-18http: don't force -fPIC if it can't be used
Not everybody can use it, even if most of the world can.
2009-09-15http: add #endif comment labels where appropriate
Sometimes I end up hacking on 10-row high terminals and need more context :x
2009-09-15http: cleanup assertion for memoized header strings
assert_frozen() should not be checking what type of object it is, instead put an extra assertion in there to ensure we have a string.
2009-09-14http: create a new string buffer on empty values
Since empty values on one line can be a heuristic to determine future lines are continuation lines (and a as a result, a decently long header), pre-allocate a string buffer just in case. This is to workaround what appears to be bug in the Rubinius C API, but it could be considered (intended) DWIM behavior, too...
2009-09-14http: use rb_str_{update,flush} if available
Rubinius supports these functions as of 039091066244cfcf483310b86b5c4989aaa6302b This allows the test_http_parser_ng.rb test to run under Rubinius db612aa62cad9e5cc41a4a4be645642362029d20
2009-09-14http: compile with -fPIC
Rubinius doesn't seem to set this by default
2009-09-14http: no-op rb_str_modify() for Rubies without it
Rubinius has no rb_str_modify() function, it /may/ not need it.
2009-09-14http: define OFFT2NUM macro on Rubies without it
Hope they have the LL2NUM macro (Rubinius does)
2009-09-14http: support Rubies without the OBJ_FROZEN macro
Rubinius does not support frozen objects, maybe other Rubies lack support for it as well.
2009-09-08"encoding: binary" comments for all sources (1.9)
This ensures any string literals that pop up in *our* code will just be a bag of bytes. This shouldn't affect/fix/break existing apps in most cases, but most constants will always have the "correct" encoding (none!) to be consistent with HTTP/socket expectations. Since this comment affects things only on a per-source basis, it won't affect existing apps with the exception of strings we pass to the Rack application. This will eventually allow us to get rid of that Unicorn::Z constant, too.
2009-09-06http: ignore Host: continuation lines with absolute URIs
This probably doesn't affect anyone with HTTP/1.1, but future versions of HTTP will use absolute URIs and maybe we'll eventually get clients that (mistakenly) send us Host: headers along with absolute URIs.
2009-09-06http: rb_gc_mark already ignores immediates
No need to add an extra check, even if it does avoid a function call.
2009-09-06http: NIL_P(var) instead of var == Qnil
This should be more inline with Ruby standards/coding style and probably more future-proof, as well.
2009-09-06http: verbose assertions
This makes it easier for bug reporters to tell us what's wrong in case line numbers change.
2009-09-06http: extra assertion when advancing p manually
Just in case, it'll be easier to track down if bugs pop up.
2009-09-06http: remove needless goto
There's no need to use a goto here to avoid one level of nesting.
2009-09-06http: use explicit elses for readability
This should make code easier to read and follow.
2009-09-06http: refactor keepalive tracking to functions
In case we modify our struct to not use bitflags, this should make it easier to change the parser code. This also adds extra clarification for how we track keepalive and why we only do it for certain request methods.
2009-09-06http: switch to macros for bitflag handling
These are similar to the macros found in MRI, and can more easily allow us to swap out the bitflags for real struct members...
2009-09-06http: clarify the setting of the actual header in the hash
Avoid a negative conditional in the process and having an explicit else in there makes this piece easier to track. Also explain /why/ the Host: header can get ignored.
2009-09-06http: cleanup and avoid potential signedness warning
Just pass the http_parser struct pointer when checking for invalid headers in the trailer. The compiler should be smart enough to inline and not relookup the flags. This avoids having to worry about the flags being signed or not (they should never be) and also makes it easier to maintain if we move away from using bitfields.
2009-09-03http: add HttpParser#headers? method
This method determines if there are headers in the request. Simple HTTP/0.9 requests did not have headers in the request (and our responses we make should not have them, either).
2009-09-02http: SERVER_PROTOCOL matches HTTP_VERSION
And it'll default to HTTP/0.9 if HTTP_VERSION is not specified (as version-less HTTP requests imply HTTP/0.9.
2009-09-01http: support for simple HTTP/0.9 GET requests
HTTP/0.9 only supports GET requests and didn't require a version number in the request line. Additionally, only a single CRLF was required. Note: we don't correctly generate HTTP/0.9 responses, yet.
2009-09-01http: extension-methods allow any tokens
ref: rfc 2616, section 5.1.1 http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1 Current version of Rack::Lint agrees with us, too. While I've yet to encounter actual usage of non-upper REQUEST_METHODs, we might as well support what Rack supports.
2009-08-29unicorn_http: "fix" const warning
neither buffer nor p should be const (since we modify buffer in $snake_upcase_char), but this is a much smaller change _for now_
2009-08-18http: support for multi-line HTTP headers
While I still consider pound to be irrelevant, but I still sometimes get hand-crafted HTTP requests that come in with multiline headers. Since these are part of the HTTP specs and not difficult to support, we might as well support them for the sake of completeness.
2009-08-18http: make strings independent before modification
Ruby strings may be copy-on-write (multiple #dup'ed strings can point to the same internal buffers). So since HttpParser#headers modifies its buffer argument, we'll need to make sure the String object we have points to its own private buffer. This doesn't affect Unicorn except in a to-be-written test case that relies on a #dup'ed String.
2009-08-17Documentation updates
* Documented Unicorn::HttpParser API methods * Keep GPL2 (COPYING) as-is without RDoc formatting. * The auto-generated index.html is stupid, replace it with README which looks saner.
2009-08-15http: support for "Connection: keep-alive"
ab still sends this with HTTP/1.0 requests, which is unfortunate, but synthetic benchmarks are good for marketing purposes!
2009-08-15http: fix warning when sizeof(off_t) == sizeof(long long)
We need to declare constants for 64-bit off_t explicitly with the "LL" suffix on 32-bit machines.
2009-08-12http: freeze fields when creating them, always
Otherwise we'll be creating an extra garbage string because rb_hash_aset can't tell the string isn't being used elsewhere and creates a new frozen one.
2009-08-11http: add "HttpParser#keepalive?" method
This should be used to detect if a request can really handle keepalives and pipelining. Currently, the rules are: 1. MUST be a GET or HEAD request 2. MUST be HTTP/1.1 3. MUST NOT have "Connection: close" set This also reduces the amount of garbage we create by globalizing constants and using them whenever possible.
2009-08-10http: add CONST_MEM_EQ macro
For comparing a raw memory space against a constant
2009-08-10http: rename read_body to filter_body
This method is strictly a filter, it does no I/O so "read" is not an appropriate name to give it.
2009-08-09http: join repeated headers with a comma
Since Rack requires a Hash object, this is joined in in accordance with rfc2616, section 4.2[1]. Of course, it's up to the framework or application to handle such requests. I could optimize this to avoid creating a single garbage String object, but I don't think it's common enough to worry about... [1] - http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
2009-08-09http: unit tests for overflow and bad lengths
We're bound by the maximum value of off_t when handling input bodies (we need to buffer to disk). Also ensure we stop bad clients that send us unparseable lengths.
2009-08-09Switch to Ragel/C-based chunk/trailer parser
This should be more robust, faster and easier to deal with than the ugly proof-of-concept regexp-based ones.
2009-08-09http: preliminary chunk decoding
2009-08-09http: process Content-Length and Transfer-Encoding
Explicitly track if our request will need Content-Length or chunked body decoding.
2009-08-09http: generic C string vs VALUEs comparison function
The macro version lets us painlessly compare Ruby strings against constant C strings. It wraps a C version of the function which is necessary to avoid double evaluation while preventing the user from having to type sizeof or strlen.
2009-08-09http: prepare http_parser struct for body processing
We'll need to keep track of a few more things to account for content/chunk length and the temporary file descriptor we'll need to use.
2009-08-09http: move non-Ruby-specific macros c_util.h
2009-08-09http: remove noise functions
It's easy enough to just check a single equality without having extra functions obscuring what's actually going on.
2009-08-09http: cleanup setting for common values => globals
We'll need to be defining g_http_transfer_encoding and g_content_length in the near future.
2009-08-09http: move global initialization code
Just extra noise we don't care about. This also allows us to undef the DEF_GLOBAL macro to avoid polluting the main namespace.
2009-08-09http: split out server params handling
It's mostly uninteresting code.
2009-08-09http: minor cleanup of http_field handling
Create a Ruby string object before jumping into the function to reduce the number of parameters passed and to take advantage of our STR_NEW macro to reduce noise.
2009-08-09http: small cleanup in "https" detection