about summary refs log tree commit homepage
path: root/test
DateCommit message (Collapse)
2009-07-04Favor Struct members to instance variables
There's a small memory reduction to be had when forking oodles of processes and the Perl hacker in me still gets confused into thinking those are arrays...
2009-07-01Force streaming input onto apps by default
This change gives applications full control to deny clients from uploading unwanted message bodies. This also paves the way for doing things like upload progress notification within applications in a Rack::Lint-compatible manner. Since we don't support HTTP keepalive, so we have more freedom here by being able to close TCP connections and deny clients the ability to write to us (and thus wasting our bandwidth). While I could've left this feature off by default indefinitely for maximum backwards compatibility (for arguably broken applications), Unicorn is not and has never been about supporting the lowest common denominator.
2009-06-30TrailerParser integration into ChunkedReader
Support for the "Trailer:" header and associated Trailer lines should be reasonably well supported now
2009-06-30trailer_parser: set keys with "HTTP_" prefix
2009-06-30chunked_reader: Add test for chunk parse failure
I'd honestly be more comfortable doing this in C (and possibly adapting the code from the libcurl internals since that code has been very well-tested).
2009-06-30Add trailer_parser for parsing trailers
Eventually this (and ChunkedReader) may be done in C/Ragel along with the existing HttpParser.
2009-06-29chunked_reader: simpler interface
This won't be heavily used enough to make preallocation worth the effort. While we're at it, don't enforce policy by forcing the readpartial buffer to be Encoding::BINARY (even though it /should/ be :), it's up to the user of the interface to decide.
2009-06-29configurator: provide stream_input (true|false) option
The default is false because some applications were not written to handle partial reads (even though IO#read allows it, not just IO#readpartial).
2009-06-29"Fix" tests that break with stream_input=false
2009-06-29test_rails: workaround long-standing 1.9 bug
Now that I've beefed out my Makefile to detect errors, I've noticed this test has been failing under 1.9 for a while now. Currently no released version of Rack(1.0) or Rails(2.3.2.1) supports this.
2009-06-29test_upload: fix ECONNRESET with 1.9
This has been broken since 6945342a1f0a4caaa918f2b0b1efef88824439e0 "Transfer-Encoding: chunked streaming input support" but somehow never caught by me or anyone else.
2009-06-29test_upload: add tests for chunked encoding
Additionally, provide verifications for sizes after-the-fact to avoid slamming all of our input into the server.
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-06-05Transfer-Encoding: chunked streaming input support
This adds support for handling POST/PUT request bodies sent with chunked transfer encodings ("Transfer-Encoding: chunked"). Attention has been paid to ensure that a client cannot OOM us by sending an extremely large chunk. This implementation is pure Ruby as the Ragel-based implementation in rfuzz didn't offer a streaming interface. It should be reasonably close to RFC-compliant but please test it in an attempt to break it. The more interesting part is the ability to stream data to the hosted Rack application as it is being transferred to the server. This can be done regardless if the input is chunked or not, enabling the streaming of POST/PUT bodies can allow the hosted Rack application to process input as it receives it. See examples/echo.ru for an example echo server over HTTP. Enabling streaming also allows Rack applications to support upload progress monitoring previously supported by Mongrel handlers. Since Rack specifies that the input needs to be rewindable, this input is written to a temporary file (a la tee(1)) as it is streamed to the application the first time. Subsequent rewinded reads will read from the temporary file instead of the socket. Streaming input to the application is disabled by default since applications may not necessarily read the entire input body before returning. Since this is a completely new feature we've never seen in any Ruby HTTP application server before, we're taking the safe route by leaving it disabled by default. Enabling this can only be done globally by changing the Unicorn HttpRequest::DEFAULTS hash: Unicorn::HttpRequest::DEFAULTS["unicorn.stream_input"] = true Similarly, a Rack application can check if streaming input is enabled by checking the value of the "unicorn.stream_input" key in the environment hashed passed to it. All of this code has only been lightly tested and test coverage is lacking at the moment. [1] - http://tools.ietf.org/html/rfc2616#section-3.6.1
2009-05-25Switch to autoload to defer requires
This should prevent Rack from being required too early on so "-I" being passed through the unicorn command-line can modify $LOAD_PATH for Rack
2009-05-22Merge branch 'benchmark'
* benchmark: Define HttpRequest#reset if missing
2009-05-22Define HttpRequest#reset if missing
Newer versions of Unicorn do not include a #reset method
2009-05-13test_response: correct OFS test
Must have multiple headers to test this effectively
2009-05-13http_response: allow string status codes
Rack::Lint says they just have to work when to_i is called on the status, so that's what we'll do.
2009-05-10Remove trickletest
This is a very important test for web servers designed to serve slow clients, but Unicorn is not that.
2009-05-10Enforce minimum timeout at 3 seconds
2 seconds is still prone to race conditions under high load. We're intentionally less accurate than we could be in order to reduce syscall and method dispatch overhead.
2009-05-04Preserve 1.9 IO encodings in reopen_logs
Ensure we preserve both internal and external encodings when reopening logs.
2009-05-04Inline and remove the HttpRequest#reset method
These potentially leaves an open file handle around until the next request hits the process, but this makes the common case faster.
2009-05-04test_signals: ready workers before connecting
Otherwise there's a chance a child won't have a socket bound by the time we're trying to connect.
2009-05-03Instant shutdown signals really mean instant shutdown
Use SIGQUIT if you're going to be nice and do graceful shutdowns. Sometimes people run real applications on this server and SIGINT/SIGTERM get lost/trapped when Object is rescued and that is not good. Also make sure we break out of the loop properly when the master is dead. Testcases added for both SIGINT and dead master handling.
2009-05-03Safer timeout handling and test case
Timeouts of less than 2 seconds are unsafe due to the lack of subsecond resolution in most POSIX filesystems. This is the trade-off for using a low-complexity solution for timeouts. Since this type of timeout is a last resort; 2 seconds is not entirely unreasonable IMNSHO. Additionally, timing out too aggressively can put us in a fork loop and slow down the system. Of course, the default is 60 seconds and most people do not bother to change it.
2009-05-03Merge commit 'origin/benchmark'
* commit 'origin/benchmark': benchmark/*: updates for newer versions of Unicorn
2009-05-03http_request: switch to readpartial over sysread
readpartial is actually as low-level as sysread is, except it's less likely to throw exceptions and won't change the blocking/non-blocking status of a file descriptor (we explicitly enable blocking I/O)
2009-05-03benchmark/*: updates for newer versions of Unicorn
* explain unicorn_peeraddr * support #readpartial in request * support #write in responses
2009-04-27test_upload: still uncomfortable with 1.9 IO encoding...
It seems most applications use buffered IO#read instead of IO#sysread. So make sure our encoding is set correctly for buffered IO#read applications, too.
2009-04-25test_request: enable with Ruby 1.9 now Rack 1.0.0 is out
2009-04-24configurator: "listen" directive more nginx-like
The following specifications to bind port 8080 on all interfaces are now accepted in the configuration file: listen "8080" # (with quotes) listen 8080 # (without quotes)
2009-04-24SIGTT{IN,OU} {in,de}crements worker_processes
This allows dynamic tuning of the worker_processes count without having to restart existing ones. This also allows worker_processes to be set to a low initial amount in the config file for low-traffic deployments/upgrades and then scaled up as the old processes are killed off. Remove the proposed reexec_worker_processes from TODO since this is far more flexible and powerful. This will allow not-yet-existent third-party monitoring tools to dynamically change and scale worker processes according to site load without increasing the complexity of Unicorn itself.
2009-04-23http_response: minor performance gains
Avoid creating garbage every time we lookup the status code along with the message. Also, we can use global const arrays for a little extra performance because we only write one-at-a time Looking at MRI 1.8, Array#join with an empty string argument is slightly better because it skips an append for every iteration.
2009-04-23test_socket_helper: disable GC for this test
Otherwise the GC will unlink sockets. A better solution (purgatory?) may be needed...
2009-04-23test_exec: cleanup stale socket on exit
2009-04-23Fix data corruption with small uploads via browsers
StringIO.new(partial_body) does not update the offset for new writes. So instead create the StringIO object and then syswrite to it and try to follow the same code path used by large uploads which use Tempfiles.
2009-04-21test: empty port test for absolute URIs
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-21Stop extending core classes
This removes the #unicorn_peeraddr methods from TCPSocket and UNIXSocket core classes. Instead, just move that logic into the only place it needs to be used in HttpRequest.
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: 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-21HttpParser: set QUERY_STRING 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-16test_upload: ensure StringIO objects are binary
Sockets always return binary encoded data, so when StringIO.new(string) is called, that StringIO object inherits the encoding of the initial string it was created with. And yes, Ruby 1.9 still makes me seriously uncomfortable with I/O manipulation since the encoding layer does things behind my back. UNIX is (and should always be) just a bag of bytes! Signed-off-by: Eric Wong <normalperson@yhbt.net>
2009-04-16Small garbage reduction in HttpResponse
Avoid creating new string objects and then discarding them right away by stuffing non-constant but always-present headers into the initial output.
2009-04-16Fix forgotten Rails tests
This was broken in 66841a0164bc03eddb7a6ac31e3923302dbc5146: ensure responses always have the "Status:" header
2009-04-16ensure responses always have the "Status:" header
There are weird (and possibly broken) clients out there that require it despite being present in the first line of the response. So be nice and accomodate them. Keep in mind that the Rack SPEC explicitly forbids this header from being in the headers returned by the Rack-based application; so we have to always inject it ourselves and ignore it if the application sets it.
2009-04-14s/rotating/reopening/g in log messages
We don't (and won't ever) do log rotation within the process. That's the job of logrotate and tools like that. We just reopen logs like other reasonable daemons out there.
2009-04-13Fix SIGINT/SIGTERM handling (broken in 0.5.0)
By reraising SignalException in workers. Since we just rely on default signal handlers for the majority of signals now, ensure those signals actually exit the process.