Date | Commit message (Collapse) |
|
Update HTTP Status Codes
|
|
IANA Source: https://www.iana.org/assignments/http-status-codes
IETF RFC 7231: https://tools.ietf.org/html/rfc7231
|
|
* Serving the rack body is wrapped in begin/ensure/end so that
body.close is guaranteed to be called per rack SPEC. When body
iteration happens inside a proc, the proc has to have its own
begin/ensure/end block to be able to make the same guarantee.
* Made my monkey patch for WEBrick::HTTPResponse follow same style as
the other monkey patch already present in the file and added a comment.
|
|
the proc"
This reverts commit a0b8fe36d456b2dd339d65836a753ff4260dd8f6.
|
|
Serving the body is wrapped in begin/ensure/end so that body.close is
always called if there are any problems. Now that looping over the body
happens in a proc, the proc has to have its own begin/ensure/end block
to guarantee the same behavior.
|
|
|
|
Fix typo in comment
|
|
|
|
case/when dispatches already optimize away allocation of constant
string literals in all C Ruby 1.9.x/2.x releases
(ref: opt_case_dispatch in Ruby insns.def)
Other Ruby implementations presumably have similar optimizations
to encourage prettier code.
The following code snippet does not cause GC.count to increase
during the two loops, regardless of what `nr' is.
Tested on Ruby 1.9.3, 2.1.3, and trunk r47786:
GET = "GET"
HEAD = "HEAD"
REQUEST_METHOD = "REQUEST_METHOD" # unnecessary in 2.2.0+
env = { REQUEST_METHOD => "GET" }
nr = 10000000
nr.times do |i|
case env[REQUEST_METHOD]
when GET, HEAD
:foo
else
:bar
end
end
a = GC.count
nr.times do |i|
case env[REQUEST_METHOD]
when "GET", "HEAD"
:foo
else
:bar
end
end
b = GC.count
p [ a, b ]
|
|
Fix: `respond_to?` takes 2 arguments
|
|
The `respond_to?` method was optimized for less object creation, unfortunately I also mangled the method signature. This commit reverts the changes introduced in #737 to `BodyProxy#respond_to?` and adds tests.
See: https://github.com/rack/rack/pull/737/files#r18359323
cc/ @raggi
|
|
Less allocated objects on each request
|
|
How many? Using `memory_profiler` and a Rails app (codetriage.com), master uses:
```
rack/lib x 7318
```
After this patch, the app uses:
```
rack/lib x 4598
```
Or `(7318 - 4598) / 7318.0 * 100 # => 37.16` % fewer objects __PER REQUEST__.
To do this, I extracted really commonly used strings into top level Rack constants. It makes for a bit of a big diff, but I believe the changes are worth it.
Running benchmark/ips against the same app, I'm seeing a performance host of `2~4%` across the entire app response. This doesn't just make Rack faster, it will make your app faster.
While we could certainly go overboard and pre-define ALL strings as constants, that would be pretty gnarly to work with. This patch goes after the largest of the low hanging fruit.
|
|
Trivial change to use single quotes for consistency
|
|
|
|
Restore Rack::Server#middleware backward compatibility
|
|
Fixes regression in #706. It intends to retain backward compatibility
with calls to #middleware by aliasing the method to the new
default_middleware_for_environment, but since it doesn't call #middleware
internally, subclasses that overrode it no longer work.
Restored compatibility by calling #middleware internally and delegating
its implementation to the new default_middleware_for_environment methods.
|
|
Preserves extension in the created tempfile
|
|
This is handy when you have to pass the generated tempfile to gems that relies on the detection of filename extension ([simple-spreadsheet](https://github.com/zenkay/simple-spreadsheet), [roo](https://github.com/Empact/roo) to name my use case).
|
|
|
|
This reverts commit e4fd87fc24a6bc10598afb83d5f572db96c241c2, reversing
changes made to d8e34e9dc9b78ca5fdb2271ef65cac8fd1c4496d.
|
|
|
|
|
|
request.port supports multiple x-http-forwarded-proto values
|
|
add quiet mode of rack server, rackup --quiet
|
|
* pr/686:
add support for application/json content type requests
|
|
* master: (62 commits)
build_nested_query includes integer values
Rack::ETag correctly marks etags as Weak
Fix yet another body close bug in Rack::Deflater
Implement full Logger interface on NullLogger
Revert "support empty string multipart filename"
support empty string multipart filename
multipart/form-data with files with no input name
Fix parent type API regression introduced in #713
correct weird case regression from #714
UrlMap: Enable case-insensitive domain matching
Raise specific exception if the parameters are invalid
Fix media_type_params when Content-Type parameters contains quoted-strings
Rack::Multipart::UploadedFile has file extensions
multipart content-type match now case insensitive
Undo test that falsely exemplifies production env
default_middleware_by_environment should always returns empty array for unknown keys
Remove rbx from Travis' allow_failures
Fix rbx settings for Travis
Use latest 2.1 on Travis
Enable cleanup of Tempfiles from multipart form data by default
...
Conflicts:
lib/rack/request.rb
|
|
max-age settings forces Set-Cookie parameter
|
|
* spastorino:
build_nested_query includes integer values
Conflicts:
lib/rack/utils.rb
|
|
Patch from @spastorino
Closes #557
|
|
Utils.build_nested_query to handle empty arrays and hashes
|
|
Implement full Logger interface on NullLogger
|
|
Configuration options for Rack::Deflate
|
|
Closes #681.
|
|
|
|
NullLogger implements only a small subset of the Logger public
interface. In case you need to hack with your loggers a bit more than
usual the NullLogger is useless since it will raise NoMethodError all
the time.
|
|
This reverts commit 9269d22c56762076e3b775ea65ec1d40494d2402.
|
|
|
|
Closes #702.
Enables support for IE11.
|
|
Closes #695.
This is not technically specification correct, but it is included for
compatibility with bad clients.
|
|
|
|
|
|
Closes #668.
Supersedes #668, because it dropped port matching.
|
|
Fix media_type_params when Content-Type parameters contains quoted-strings
|
|
Raise specific exception if the parameters are invalid
|
|
There are some cases where we try to parse the parameters but it fails
with ArgumentError.
1. When the parameters come from the query string and contains invalid
UTF-8 characters. In this case we raise ArgumentError when trying to
match the key portion of parameters with a regexp.
2. When the parameters come from the request body and the query string
contains invalid % encoded string. In this case we raise ArgumentError
when calling URI.decode_www_form_component.
Now both cases raise a InvalidParameterError what inherit from TypeError
and we can catch this exception to show a bad request for users instead
of an internal server error.
|
|
According RFC 2616, the Content-Type parameters value can be even a token or
a quoted-string:
media-type = type "/" subtype *( ";" parameter )
type = token
subtype = token
parameter = attribute "=" value
attribute = token
value = token | quoted-string
quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
qdtext = <any TEXT except <">>"
quoted-pair = "\" CHAR
|
|
Tempfiles created for file uploads now have file extensions. This enables
certain use cases for users that are using file extensions as heuristics.
Closes #690
|
|
Closes #676
This may not be 100% to spec, but it is important for compatibility and should
not cause regressions.
|
|
Monkey patch to fix WEBrick chunking semantics.
|