summary refs log tree commit
DateCommit message (Collapse)
2017-06-29deflater: reduce live Time objects deflater
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
2017-06-29deflater: additional mtime tests
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.
2017-06-29deflater: support "sync: false" option
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.
2017-06-29deflater: avoid wasting an ivar slot on @closed
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.
2017-06-29deflater: rely on frozen_string_literal
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.
2017-06-28Partially reverting 8a7a142d
Thanks pmc@citylink.dinoex.sub.org for the patch
2017-05-30Require the right file for the digest we're using
2017-05-15Merge pull request #1163 from janko-m/rely-on-size-in-mock-request
Rely on input responding to #size instead of #length in MockRequest.env_for
2017-05-15Merge pull request #1166 from jnraine/master
Safely handle modules in `Rack::Session::Abstract::ID` subclass ancestor list
2017-05-12Safely handle modules in hierarchy
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 ```
2017-05-12Ensure env values are ASCII 8BIT encoded
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.
2017-05-08Stop splatting clean array
File.join supports an array parameter so we don't need to expand the array to be mulitple parameters for File.join.
2017-05-08Revert "updating author / email"
This reverts commit 7ca86b7c42def1865f032c4d71c01ea94584b470.
2017-05-01Don't require input to respond to #size in MockRequest.env_for
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.
2017-05-01Rely on input #size instead of #length in MockRequest.env_for
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.
2017-04-26Merge pull request #1161 from junaruga/feature/update-travis
Update .travis.yml
2017-04-22Update .travis.yml
2017-04-19Merge pull request #1154 from tricknotes/remove-mongrel
Remove "mongrel" from server option's description
2017-04-17Remove "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.
2017-03-27Merge pull request #1150 from wikimatze/master
Add Padrino to the supported web frameworks
2017-03-27Merge pull request #1151 from cremno/simplify-some-string-creations
Simplify some string creations
2017-03-25call String#b to create a binary copy
2017-03-25remove superflous String#force_encoding calls
String.new with no arguments already returns binary strings.
2017-03-25Add Padrino to the supported web frameworks
2017-03-21Merge pull request #1149 from jeremyevans/freeze-app
Add Builder#freeze_app to freeze application and all middleware instances
2017-03-14Add 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.
2017-02-23Merge pull request #1144 from nanaya/httpdate-for-expires
Use .httpdate for expires date formatting
2017-02-23Merge pull request #1117 from ioquatix/patch-3
Fix warnings and usage of $VERBOSE
2017-02-19Use .httpdate for expires date formatting
Specified in RFC 7231, section 7.1.1.2: Date.
2017-02-15Merge branch 'rfc7231-sec6.3.6-205'
* rfc7231-sec6.3.6-205: Revert "Add 205 Reset Content to the list of statuses without a message body"
2017-02-15Merge branch 'no-deflate'
* no-deflate: deflater: remove "deflate" encoding support
2017-01-25Merge pull request #1141 from brauliomartinezlm/bytesize_usage
Update bytesize usage after its removal from rack utils
2017-01-24Update bytesize usage after its removal from rack utils
2016-12-29Merge pull request #1137 from unabridged/fix-eof-failure
Fix MethodOverride EOFError failure
2016-12-29Write MethodOverride errors to RACK_ERRORS
2016-12-29Resolve undefined constant test failure by loading constant
2016-12-29Minimal resolution of EOFError in MethodOverride middleware
2016-12-14Revert "Add 205 Reset Content to the list of statuses without a message body" rfc7231-sec6.3.6-205
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.
2016-12-08Merge pull request #1135 from tonytonyjan/patch-rdoc
Add rdoc dependency
2016-12-08add rdoc dependency
2016-12-07Merge pull request #1133 from tonytonyjan/patch-typo
fix typo
2016-12-07Merge pull request #1132 from tonytonyjan/patch
typo fix
2016-12-07fix typo
2016-12-06typo fix
2016-12-05Merge pull request #1130 from tonytonyjan/patch
To support minitest 6 and prevent error message from minitest 5.
2016-12-05To support minitest 6 and prevent error ouput in minitest 5, use ↵
`must_be_nil` if expecting nil.
2016-11-28Merge pull request #1128 from dijonkitchen/patch-1
Change NEWS file into Markdown file extension
2016-11-27Change NEWS file into Markdown file extension
This way GitHub will render it correctly in browser.
2016-11-25Merge pull request #973 from mwpastore/master
Update example use of Rack::Deflater
2016-11-10Merge pull request #1080 from sophiedeziel/master
Prevent exception caused by a race condition on multi-threaded servers