about summary refs log tree commit homepage
path: root/ext
DateCommit message (Collapse)
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
2009-08-09http: "hp" denotes http_parser structs for consistency
It doesn't conflict with any any common variables, tokens or documentation pieces in the code.
2009-08-09http: remove some redundant functions
Eliminate unnecessary jumping around in the source code to find actions that lead to other actions and making it harder to notice side effects when dealing with data we're sharing anyways.
2009-08-09http: split uncommon_field into a separate function
There's also no point in validating field hits if our field is a common field; so only do the validation for field length if we need to allocate memory for a new field.
2009-08-09http: find_common_field_value => find_common_field
The "_value" suffix was used to denote the return type, which is redundandant as it is already known at compile time (being that this is C and functions have explicit return types). Furthurmore, the "_value" is confusing since we're actually returning a "key" when "value" is used in the context of "key-value" pairs.
2009-08-09Refactoring unicorn_http C/Ragel code
More tightly integrate the C/Ruby portions with C/Ragel to avoid the confusing the flow. Split out some files into hopefully logical areas so it's easier to focus on more interesting/volatile code.
2009-08-09extconf: SIZEOF_OFF_T should be a ruby.h macro
Only fallback to check_sizeof() if it is not. check_sizeof() is broken in Ruby 1.9.2preview1 (but fixed in trunk).
2009-08-09unicorn_http: add helpful macros
We'll be needing the UH_OFF_T_MAX define for the chunked body handling and rb_str_set_len may be needed as well.
2009-08-09unicorn_http: change "global_" prefix to "g_"
It's too annoying to have to deal with long prefixes that all look alike. "g_" is fairly standard in C programs so I'm keeping it (even though eliminating the prefix entirely is preferable, but there'd be name conflicts I don't feel like resolving).
2009-08-09unicorn_http: update copyright
So that blame falls on Eric if stuff breaks.
2009-08-09unicorn_http: remove typedef from http_parser
typedefs can be misleading for aggregate types, a struct is a struct.
2009-08-09Remove Ragel-generated file from version control
But keep it in the Manifest
2009-08-09unicorn_http: small cleanups and size reduction
Use Data_Make_Struct instead of Data_Wrap_Struct to avoid extra steps/code in object allocation. The GC will also free() implicitly if no free callback is passed to Data_Make_Struct, and we don't need an extra method here... Since we're more comfortable with object management nowadays, just make the data_get() fail with an assertion failure if it somehow (very unlikely) ends up getting a NULL parser object. Unicorn itself has no way of recovering other than throwing errors to clients anyways and we have bigger problems if there's a GC bug causing this. Then, finally, reduce the size of our http_parser struct even more (we'll add an int back later) since we know it's safe to do so...
2009-07-15Rename unicorn/http11 => unicorn_http
We couldn't do proper namespacing for the C module so there was a potential conflict with Init_http11() in Mongrel. This was needed because Mongrel's HTTP parser could be used in some applications and we may be unfortunate enough need to support them.
2009-06-10Optimize body-less GET/HEAD requests (again)
No point in making syscalls to deal with empty bodies. Reinstate usage of the NULL_IO object which allows us to avoid allocating new objects.
2009-04-21http11: support underscores in URI hostnames
They aren't common, but apparently there exist URLs with them, so we'll support them.
2009-04-21http11: rfc2616 handling of absolute URIs
We now parse the scheme, host and port from Absolute URIs and ignore them if the equivalents are specified in the other headers.
2009-04-21http11: cleanup some CPP macros
Use the "do {} while (0)" idiom to wrap the macros we can wrap to avoid having to worry about semi-colons when using them. Unfortunately DEF_MAX_LENGTH can't be wrapped with "do {} while (0)". But we do now correctly constify the strings DEF_MAX_LENGTH creates and also make them static to reduce visibility.
2009-04-21http11: make parser obey HTTP_HOST with empty port
This means "Host: foo-bar:" (trailing colon) will assume server_port is 80, not a blank string.
2009-04-21http11: minor cleanups in return types
While we're at it, replace a bunch of zero assignments with a memset to avoid forgetting a struct element in case we change the struct.
2009-04-21replace DATA_GET macro with a function
I don't see the point of using a macro here as it's never called in a hot path. It's a very minor size reduction in the binary, but also makes the rest of the code less noisy/screamy.
2009-04-21http11: remove callbacks from structure
There's no point in having redefinable callbacks if they're always going to be pointed to the same function. This reduces the size of the http_parser structure to half its original size. This change may actually make more sense in servers Mongrel/Thin than Unicorn since Unicorn only has one parser per-process while other servers can have hundreds or even thousands.
2009-04-21http11: formatting cleanups
2009-04-21HttpParser: set QUERY_STRING for Rack-compliance
2009-04-21http11: remove unused variables/elements
We don't do anything special with content length in the parser other than forcing the headers without the "HTTP_" prefix for Rack-compliance.
2009-04-21Move absolute URI parsing into HTTP parser
It's part of the HTTP/1.1 (rfc2616), so we might as well handle it in there and set PATH_INFO while we're at it. Also, make "OPTIONS *" test not fail Rack::Lint
2009-04-21http11: cleanup #includes and whitespace
Remove ctype.h and stdio.h #includes. We avoid ctype.h functions since it is locale-dependent and HTTP itself is locale-independent. Also, regenerate http11_parser.c against Ragel 6.4
2009-04-15http11: default server port is 443 for https
Also, some minor cleanups and branch refactoring.
2009-04-12http11: cleanup+safer rack.url_scheme handling
Avoid using strcmp() since it could break badly if Ruby ever stopped null-terminating strings C-style. We're also freezing "http" as a global. Rack does not explicitly permit nor deny this, and Mongrel has always used frozen strings as hash values in other places.
2009-04-08http11: handle "X-Forwarded-Proto: https"
Pass "https" to "rack.url_scheme" if the X-Forwarded-Proto header matches "https". X-Forwarded-Proto is a semi-standard header that Ruby frameworks seem to respect; so we use that. We won't support ENV['HTTPS'] since that can only be set at start time and some app servers supporting https also support http. Currently, "rack.url_scheme" only allows "http" and "https", so we won't set anything else to avoid breaking Rack::Lint.