aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/response.rb
Commit message (Collapse)AuthorAgeFilesLines
* [Action Pack] require => require_relativeAkira Matsuda2017-10-211-2/+2
| | | | | This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f, d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
* Decouple the merge/normalization and conditional cache control logicPatrick Toomey2017-08-231-0/+1
| | | | | | | | | | | | | | | | The prior logic was trying to do too many things at once. For all responses, we want to perform two distinct steps: * Merge/normalize the `Cache-Control` values found in HTTP headers and those found in the `@cache_control` hash. * Conditionally set a default `Cache-Control` header value when we have an ETag This change separates these concerns since the merge/normalize step should occur for all responses, but the second should only occur when we have already set an ETag/last modified value. Normally ETag middleware will set a default `Cache-Control`, but only if an existing ETag is not already set. So, in the cases where an ETag is set, we need to set the default `Cache-Control` value ourselves.
* Merge pull request #29777 from yui-knk/set_content_typeMatthew Draper2017-08-021-3/+2
|\ | | | | Refactoring `Response#charset=`
| * Brush up local variables assignmentyui-knk2017-07-131-3/+2
| |
| * Use `#set_content_type` instead of `#set_header`yui-knk2017-07-131-1/+1
| | | | | | | | | | | | By this commit, `#set_header` is called only via `#set_content_type`. This commit makes the role of `#charset=` more clear.
* | Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
| |
* | `Response#charset=` uses `default_charset` when `nil` is passedyui-knk2017-07-131-1/+1
|/
* Merge branch 'master' into require_relative_2017Xavier Noria2017-07-021-1/+1
|\
| * Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
| * Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-021-0/+1
| |\ | | | | | | | | | Enforce frozen string in Rubocop
| | * Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
| | |
| * | Make ActionMailer frozen string literal friendly.Pat Allan2017-06-201-1/+1
| |/
* / [Action Dispatch] require => require_relativeAkira Matsuda2017-07-011-2/+2
|/
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-2/+2
|
* [docs] fix ActionDispatch documentationHrvoje Šimić2017-03-131-2/+2
|
* Current default Rails app encoding "utf-8" looks more like a W3C charset ↵Akira Matsuda2017-01-111-1/+1
| | | | than a ruby encoding
* Only default the response charset when it is first setMatthew Draper2016-12-201-1/+3
| | | | | If it is explicitly cleared (e.g., response.sending_file = true), then we should not try to set it again.
* Do not raise exception when content_type is a empty stringRafael Mendonça França2016-12-091-1/+1
| | | | | When content type header is blank we were raising an exception because `empty?` was being called on nil.
* Merge pull request #26905 from bogdanvlviv/docsAndrew White2016-11-131-1/+1
|\ | | | | Add missing `+` around a some literals.
| * Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | | | | | | | Mainly around `nil` [ci skip]
* | Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|/
* Remove default argument, and extract internal convenience methodJon Moss2016-08-291-6/+12
|
* Allow `send_file` to declare a charsetJon Moss2016-08-291-4/+5
| | | | | | Removed my patch in favor of @tenderlove's less invasive approach. [Aaron Patterson & Jon Moss]
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
|
* modernizes hash syntax in actionpackXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-11/+11
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fixes #23964Ryan T. Hosford2016-03-131-9/+24
| | | | | | | | | | | | | | | | | | - Adds #each_chunk to ActionDispatch::Response. it's a method which will be called by ActionDispatch::Response#each. - Make Response#each a proper method instead of delegating to @stream - In Live, instead of overriding #each, override #each_chunk. - `#each` should just spit out @str_body if it's already set - Adds #test_set_header_after_read_body_during_action to prove this fixes #23964 - Adds #test_each_isnt_called_if_str_body_is_written to ensure #each_chunk is not called when @str_body is available - Call `@response.sent!` in AC::TestCase's #perform so a test response acts a bit more like a real response. Makes test that call `#assert_stream_closed` pass again. - Additionally assert `#committed?` in `#assert_stream_closed` - Make test that was calling @response.stream.each pass again by calling @response.each instead.
* add missing requireAaron Patterson2016-02-051-0/+1
|
* Space OddityAkira Matsuda2016-01-141-1/+1
| | | | | Converting nbsp(\u{00A0}) to the normal ASCII space(\u{0020}) [ci skip]
* Commit before freezing the headersMatthew Draper2016-01-121-0/+7
| | | | | This shouldn't generally come up: under a standard flow, we don't start sending until after the commit. But application code always finds a way.
* Only commit the cookie jar if it hasn't been committedeileencodes2015-12-061-1/+1
| | | | | | | We don't want to commit the cookie jar more than once because then we will be attempting to modify a frozen hash. Fixes Railties test failure caused by 492b134.
* Stop violating law of demeter in response cookie_jareileencodes2015-12-061-1/+1
| | | | | | | | | | | This adds a new method to request and response so we don't need to violate the law of demeter. We are changing `Request` and `Response` so that they always have a `cookie_jar` This is a continuation on work to combine integration and controller test code bases in Rails.
* Push `before_sending` to super classeileencodes2015-12-061-0/+2
| | | | | | | | | | | | We want to get rid of the `Live::Response` so we are consolidating methods from `Live::Response` and `Response` by merging them together. This adds an `#empty` method to the request so we don't need to hard-code the empty array each time we call an empty `ActionDispatch::Request`. The work here is a continuation on combining controller and integration test code bases into one.
* Remove dead codeRafael Mendonça França2015-10-281-5/+0
| | | | This is leftover from when `render nothing: true` rendered blank string.
* use methods for accessing the cache control headersAaron Patterson2015-10-061-0/+4
| | | | | Use the methods rack provides so we don't have to worry about the exact header key.
* Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-1/+1
| | | | | | | | | | | | | | | | | Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries that support multiple Rails versions would've had to feature-detect whether to use `Mime::Type[:FOO]` or `Mime::FOO`. `Mime[:foo]` has been around for ages to look up registered MIME types by symbol / extension, though, so libraries and plugins can safely switch to that without breaking backward- or forward-compatibility. Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup by type or extension, so it's not available as `Mime[:all]`. We use it internally as a wildcard for `respond_to` negotiation. If you use this internal constant, continue to reference it with `Mime::ALL`. Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
* move file sending to the response objectAaron Patterson2015-10-051-1/+39
| | | | | | | Just a slight refactor that delegates file sending to the response object. This gives us the advantage that if a webserver (in the future) provides a response object that knows how to do accelerated file serving, it can implement this method.
* Introduce `Headers#add`. Move `Response#add_header` upstream.Jeremy Daer2015-10-031-21/+1
| | | | | | | * Introduce `ActionDispatch::Http::Headers#add` to add a value to a multivalued header. * Move `Response#add_header` upstream: https://github.com/rack/rack/pull/957 * Match upstream `Response#have_header?` -> `#has_header?` name change.
* Response#add_header for adding to multi-valued headers like VaryJeremy Daer2015-10-011-0/+20
|
* move the Header hash to the super classAaron Patterson2015-09-241-1/+24
| | | | | | | I want to move the header hash to the super request object in order to consolidate behavior. We should be switching out buffering strategies rather than header strategies since things like "mutating headers after send" is an error in both cases (buffering vs streaming).
* mutate headers before committing the responseAaron Patterson2015-09-241-2/+8
| | | | We should not mutate headers after the response has been committed.
* stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-231-6/+10
| | | | | | | | | | I'm making this change so that I can construct response objects that *don't* have the default headers applied. For example, I would like to construct a response object from the return value of a controller. If you need to construct a response object with the default headers, then please use the alternate constructor: `ActionDispatch::Response.create`
* stop calling deprecated methodsAaron Patterson2015-09-211-1/+1
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* `rack_response` should use the status it's givenAaron Patterson2015-09-141-1/+1
|
* mime_type will always return a stringAaron Patterson2015-09-081-2/+1
|
* remove `parse_content_type` parameterAaron Patterson2015-09-081-6/+7
| | | | | This method is specifically about the content type so lets remove the parameter.
* avoid allocations when there is no content type setAaron Patterson2015-09-081-1/+2
| | | | | create a singleton content type that just has nils, so that we don't have to allocate a content type object all the time.
* handle implicit rendering correctlyAaron Patterson2015-09-081-3/+4
| | | | | | | If someone sets just a charset, but depends on the implicit type from rendering, this will store a strange content type header that looks like this: `; charset=blah`. This is so that when the content type header is parsed again, it will return nil for the actual type.
* remove mime type lookups when parsing the content typeAaron Patterson2015-09-081-5/+5
| | | | | It turns out that the response object never really cares what the mime type object is, so just use the string.
* refactor content type settingAaron Patterson2015-09-081-44/+39
| | | | pull content-type setting to a private method to dry it up.