summaryrefslogtreecommitdiff
path: root/test/spec_response.rb
Commit message (Collapse)AuthorAgeFilesLines
* Handle string reuse by body.each when buffering bodies in Rack::Response (#2044)Jeremy Evans2023-03-241-0/+20
| | | | | | | An alternative approach would be using a single string inside an array and appending to that. This approach is more backwards compatible, but results in more memory usage. Fixes #1957
* Prefer lowercase "samesite" property name for cookies. (#2008)Samuel Williams2023-01-131-25/+25
|
* Allow passing through streaming bodies. (#1993)Samuel Williams2022-12-051-0/+10
|
* Trim trailing white space throughout the project (#1990)Jon Dufresne2022-12-031-2/+2
| | | | | | Many editors clean up trailing white space on save. By removing it all in one go, it helps keep future diffs cleaner and eases new contributions by avoiding spurious white space changes on unrelated lines.
* Remove deprecated code. (#1966)Samuel Williams2022-09-101-4/+0
|
* Add 100% line/branch coverage to rack/response.rbJeremy Evans2022-05-071-1/+75
| | | | | | | Coverage after this commit: 3305 relevant lines, 3266 lines covered and 39 lines missed. ( 98.82% ) 1133 total branches, 1039 branches covered and 94 branches missed. ( 91.7% )
* Add methods for HTTP status codes 406 and 408 (#1882)Jason Garber2022-04-281-0/+10
| | | | | | | | | | | | This commit adds two new predicate methods to the `Rack::Response` class: - `not_acceptable?` which returns true on HTTP 406 Not Acceptable - `request_timeout?` which returns true on HTTP 408 Request Timeout Links to MDN documentation for each status code: - https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406 - https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408
* Tidy up documentation and specs in relation to lower case headers. (#1855)Samuel Williams2022-04-111-90/+87
|
* Use lower case normalisation for cookie attributes. (#1849)Samuel Williams2022-04-061-2/+2
|
* Don't bother pattern matching existing set-cookie for deletion. (#1844)Samuel Williams2022-04-061-54/+46
|
* Fix verbose warnings in specsJeremy Evans2022-03-031-6/+6
|
* Allow header value to be an Array of String instances. (#1793)Samuel Williams2022-03-021-25/+29
| | | | | * Allow headers to be an Array of String instances. * Add deprecated compatibility shims.
* Change SPEC to not allow uppercase header keysJeremy Evans2022-02-181-11/+11
| | | | | | Also, update CHANGELOG with other spec changes made since 2.2. Implements #1592
* Enable directly requiring Rack componentsJeremy Evans2022-02-031-0/+4
| | | | | | | | | | | | | | | | | | | | | Add test:separate task to test run each test file separately. This is to test that directly requiring a rack component will work. With test:separate, the test helper will not require rack, and each test file should call separate_testing with a block that uses require_relative to only require that component being tested. Add the appropriate relative requires to get all tests passing when run separately. Note that this isn't foolproof. In many cases, the tests use Rack components that are not under test (such as lint and mock), and both of those other other rack components, so it's possible the tests are loading hidden dependencies. I attempted to check each component to try to find the hidden dependencies, but it is certainly possible I missed something. Implements #1621.
* Convenient cache and content type methods for `Rack::Response`.Samuel Williams2020-02-051-0/+33
|
* Memoize header hash usage. Fixes #738.Samuel Williams2020-02-051-6/+6
|
* Add remaining covering testsJeremy Evans2020-01-301-4/+6
| | | | 3378 / 3378 LOC (100.0%) covered
* Fix Response#write calculation of Content-Length if initialized with a bodyJeremy Evans2020-01-291-5/+32
| | | | | | | | | | | | | | | | | | Before, @length was always set to 0 in the constructor. The breaks the case where a string was provided, since that is automatically bufferred. Fix that by using the bytesize of the string. If body was provided as an array, when switching to buffered mode, iterate over the body to figure out the content length. Note this only occurs when doing Response#write, as that is the only case where Response updates the Content-Length. I found one spec that called Response#write inside a Response#finish block. That updates the response body after the header hash is returned, and does not call Response#append as the @writer has been changed to the Response#finish block, so it doesn't update the Content-Length in the returned header hash.
* DRY up tests using the test helperJeremy Evans2020-01-271-4/+1
| | | | | | For some reason, the test helper was only used by a single spec file. This uses it for all spec files. While here, rely on autoload loading the libraries instead of loading everything manually.
* Do more exact matching of domain and path when deleting cookiesJeremy Evans2020-01-231-0/+77
| | | | | | | Also, correctly handle deleting with both a domain and path provided. Fixes #1234
* Enable `Layout/TrailingWhitespace` cop to prevent extra trailing space in futureRyuta Kamizono2020-01-221-1/+1
|
* Add new `Response.[]` and `MockResponse.[]` which are very similar. Fixes #1094.Samuel Williams2020-01-141-0/+11
|
* Restore part of status=205 spec.rack-response-bufferedSamuel Williams2020-01-071-0/+9
|
* Lazily initialize the response body and only buffer it if required.Samuel Williams2020-01-071-9/+25
| | | | | | | | The implementation of `Rack::Response` will double buffer every body even if the user does not call `#write`. This is inefficient and additionally imposes some type checking overhead even if none is wanted. Fixes <https://github.com/socketry/falcon/issues/93>.
* Improve spec compatibility with current master.to_ary-flattenSamuel Williams2020-01-071-2/+2
|
* Improve spec name and be explicit about result.Samuel Williams2020-01-071-3/+4
|
* Remove `to_ary` from Responserm_to_ary_from_responseAaron Patterson2020-01-061-2/+2
| | | | | | | | Responses are not arrays, so we should not allow them to be implicitly coerced to an array. If you would like you response to be converted to an array, you must explicitly do it with the `to_a` method. This also prevents creation of unnecessary body proxies
* Allow global expectation explicitly for minitest.Nikolay Rys2019-10-061-1/+1
| | | | Global expectations have been deprecated in minitest and will start fail in the upcoming major release. Right now it results in multiple warnings. We need to allow them explicitly. Also fixing spacing style in gemspec.
* Added support for SameSite=None cookie value, added in revision 3 of rfc6265bisHenning Kulander2019-05-091-0/+18
| | | | | - https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#appendix-A.4 - Indicates that cookie is used as a third party cookie.
* Merge pull request #1325 from jodosha/performance/remove-useless-header-mergeAaron Patterson2019-04-021-0/+10
|\ | | | | Performance: remove useless header merge from Response
| * Don't mutate given headersLuca Guidi2019-01-041-0/+10
| |
* | Introduce Rack::SimpleBodyProxyLuca Guidi2018-12-191-2/+2
|/
* RuboCop: enable Layout/Space* cops (#1259)yhirano552018-04-171-21/+21
|
* Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b } (#1253)yhirano552018-04-161-24/+24
| | | | | | | Use Ruby >= 1.9 syntax for hashes * Required Ruby version is >= 2.2, so It's better to use prefer `{ a: :b }` over `{ :a => :b }` in hash syntax. * It's hard to modify manufally all points, so I've installed rubocop and enabled only `Style/HashSyntax` (All cops are disabled by default) * Executed `rubocop --auto-correct`
* Add frozen_string_literal: true to remaining filesDillon Welch2018-04-131-0/+2
| | | | See https://github.com/rack/rack/issues/1243 for history of this task
* Updates for frozen string literal compatibility.Pat Allan2017-06-211-5/+5
|
* Use .httpdate for expires date formattingnanaya2017-02-191-5/+5
| | | | Specified in RFC 7231, section 7.1.1.2: Date.
* Revert "Add 205 Reset Content to the list of statuses without a message body"Eric Wong2016-12-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* To support minitest 6 and prevent error ouput in minitest 5, use ↵Jian Weihang2016-12-051-3/+3
| | | | `must_be_nil` if expecting nil.
* Validate the SameSite cookie optionBob Long2016-04-171-4/+42
| | | | | | | | | | | | | | | The draft spec for the SameSite option mentions two configuration options: Strict & Lax. This commit introduces validation of the associated same_site attribute. The main motivation for validating this value is ensuring that awry option values don't cause unexpected behaviour. As this is a sensitive security option, I think validation is warranted. The main drawback of validating the option value is that Rack won't immediately support new options. Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* first-party cookies are now same-site cookiesBen Toews2016-03-151-5/+17
| | | | | | | | | | remove use of `:first_party` option pass along provided value make the syntax more flexible s/strict/Strict/
* First-Party cookies, another line of CSRF defenseJeremy Daer2015-12-041-0/+14
| | | | | | | | Set `first_party: true` to set the First-Party attribute telling browsers to only send the cookie with legit first-party requests. * https://tools.ietf.org/html/draft-west-first-party-cookies-00 * https://www.chromestatus.com/feature/4672634709082112
* * Add `Rack::Response::Helpers#cache_control` and `cache_control=`.Aaron Patterson2015-10-061-0/+9
| | | | Use this for setting cache control headers on your response objects.
* * Add `Rack::Response::Helpers#etag` and `etag=`. Use this forAaron Patterson2015-10-061-0/+7
| | | | setting etag values on the response.
* `Response#add_header` to add to a value to a multivalued headerJeremy Daer2015-10-031-0/+68
| | | | | | | | | | | * Introduce `Rack::Response::Helpers#add_header` to add a value to a multi-valued response header. Implemented in terms of other `Response#*_header` methods, so it's available to any response-like class that includes the `Helpers` module. * Add `Rack::Request#add_header` to match. * Rename `Response#have_header?` to `#has_header?` to match existing `Request#has_header?` * Add test coverage for this and other `*_header` methods.
* Rack::Response::Helpers#redirect? would accept 308 status codedeepj2015-08-291-3/+12
| | | | | | | 308 status code is ‘Permanent Redirect’ (see http://greenbytes.de/tech/webdav/draft-reschke-http-status-308-07.html) and `Rack::Response::Helpers#redirect?` would accept it as a redirection when 308 status is supported by Rack.
* Remove any reference to 418 status codedeepj2015-08-291-5/+0
| | | | | It was removed in Rack 1.6 from HTTP status codes. See https://github.com/rack/rack/pull/754
* First attempt to mass-port from minitest/bacon to minitest/spec.Ryan Davis2015-06-121-105/+105
| | | | | I still can't run some of the tests, so they might have problems. I'll leave it to the CI to catch them.
* Added minitest/bacon to the top of each file so they can be run straight up.Ryan Davis2015-06-111-0/+1
|
* Make all tests run and pass independently.Ryan Davis2015-06-111-0/+1
|