Date | Commit message (Collapse) |
|
Only create a Time object if the Last-Modified header exists,
(immediately use the Integer result of Time#to_). Otherwise, we
can rely on the default behavior of Zlib::GzipWriter of setting
the mtime to the current time.
While we're at it, avoid repeating the hash lookup for
Last-Modified.
This results in an improvement from 11.0k to 11.4k iterations/sec
with the following script:
require 'benchmark/ips'
require 'rack/mock'
req = Rack::MockRequest.env_for('', 'HTTP_ACCEPT_ENCODING' => 'gzip')
response = [200, {}, []]
deflater = Rack::Deflater.new(lambda { |env| response })
Benchmark.ips do |x|
x.report('deflater') do
s, h, b = deflater.call(req)
b.each { |buf| }
b.close
end
end
|
|
The next commit will reduce long-lived Time objects. Regardless
of whether that commit is acceptable, having extra tests for
existing mtime behavior cannot hurt.
For testing responses with the Last-Modified header, setting a
random date in the past should make failure to preserve mtime
in the gzip header more apparent.
|
|
Flushing after after very flush is great for real-time apps.
However, flushing is inefficient when apps use Rack::Response
to generate many small writes (e.g. Rack::Lobster).
Allow users to disable the default "sync: true" behavior to
reduce bandwidth usage, otherwise using Rack::Deflater can lead
to using more bandwidth than without it.
|
|
We can merely set the @body to nil ensure we do not call close
on the @body, twice. Saving an ivar slot can save 8 bytes
per object at minimum, and this makes me feel more comfortable
about using another ivar for the next commit.
|
|
This improves readability of our code and can allow us to
generate less garbage in Ruby 2.3+ for places where we didn't
already use constants. We can also avoid the old constant
lookups (and associated inline cache overhead) this way.
|
|
Thanks pmc@citylink.dinoex.sub.org for the patch
|
|
|
|
Rely on input responding to #size instead of #length in MockRequest.env_for
|
|
Safely handle modules in `Rack::Session::Abstract::ID` subclass ancestor list
|
|
Adds a check before calling `superclass` on an ancestor of a subclass of `Rack::ID` to avoid calling `superclass` on `Module`, which does not implement it.
Here is an code example that causes exercises this special case:
```ruby
ID = Class.new
IDChild = Class.new(ID)
MyMod = Module.new
Foo = Class.new(IDChild)
Foo.include(MyMod)
Foo.ancestors.find { |kl| kl.superclass == ID }
# NoMethodError: undefined method `superclass' for MyMod:Module
Foo.ancestors.find { |kl| kl.respond_to?(:superclass) && kl.superclass == ID }
# => IDChild
```
|
|
When web servers read data from the socket it's encoded as ASCII_8BIT
because we don't know the encoding. This change makes the env closer to
what a real web server will return in production.
|
|
File.join supports an array parameter so we don't need to expand the
array to be mulitple parameters for File.join.
|
|
This reverts commit 7ca86b7c42def1865f032c4d71c01ea94584b470.
|
|
The #size method isn't part of the Rack input specification, so
technically the given Rack input object doesn't have to respond to
\#size.
This allows us to test our Rack applications with Rack input that
doesn't respond to #size, verifying that we're not relying on it.
|
|
StringIO is the only IO object that responds to #length, the Ruby IO
interface actually uses #size. Furthermore #size is actually implemented
on IO-like inputs on web servers like Unicorn and Passenger (TeeInput).
This change allows using (Temp)file objects as the Rack input.
|
|
Update .travis.yml
|
|
|
|
Remove "mongrel" from server option's description
|
|
Currently [mongrel](https://github.com/mongrel/mongrel) is not maintained.
And it couldn't be built with any Ruby versions that supported by Rack.
|
|
Add Padrino to the supported web frameworks
|
|
Simplify some string creations
|
|
|
|
String.new with no arguments already returns binary strings.
|
|
|
|
Add Builder#freeze_app to freeze application and all middleware instances
|
|
Freezing the application and middleware instances can prevent
thread-safety issues at runtime. This addresses the issues
discussed in #1010.
Unlike the solution proposed by #1010, this is backwards compatible
as it is opt-in, the application and middleware instances are
only frozen if you choose to use freeze_app.
|
|
Use .httpdate for expires date formatting
|
|
Fix warnings and usage of $VERBOSE
|
|
Specified in RFC 7231, section 7.1.1.2: Date.
|
|
* rfc7231-sec6.3.6-205:
Revert "Add 205 Reset Content to the list of statuses without a message body"
|
|
* no-deflate:
deflater: remove "deflate" encoding support
|
|
Update bytesize usage after its removal from rack utils
|
|
|
|
Fix MethodOverride EOFError failure
|
|
|
|
|
|
|
|
RFC 7231, section 6.3.5 gives three possible options for what a
server MUST do when sending a 205 status code:
> Since the 205 status code implies that no additional content will be
> provided, a server MUST NOT generate a payload in a 205 response. In
> other words, a server MUST do one of the following for a 205
> response: a) indicate a zero-length body for the response by
> including a Content-Length header field with a value of 0; b)
> indicate a zero-length payload for the response by including a
> Transfer-Encoding header field with a value of chunked and a message
> body consisting of a single chunk of zero-length; or, c) close the
> connection immediately after sending the blank line terminating the
> header section.
rack itself has no control over c), but should leave options
a) and b) available for middleware and application authors.
https://tools.ietf.org/html/rfc7231#section-6.3.6
The older RFC 2616 text was vague and not specific about
what a server should do:
https://tools.ietf.org/html/rfc2616#section-10.2.6
I noticed this from Plack: https://metacpan.org/pod/Plack::Util
This reverts commit 2c5b076aaba6c83ffce8c6c2b5c49085c1abb5a5.
|
|
Add rdoc dependency
|
|
|
|
fix typo
|
|
typo fix
|
|
|
|
|
|
To support minitest 6 and prevent error message from minitest 5.
|
|
`must_be_nil` if expecting nil.
|
|
Change NEWS file into Markdown file extension
|
|
This way GitHub will render it correctly in browser.
|
|
Update example use of Rack::Deflater
|
|
Prevent exception caused by a race condition on multi-threaded servers
|