aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/mime_responds.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use match? where we don't need MatchDataAkira Matsuda2019-07-291-1/+1
|
* Change `ActionDispatch::Response#content_type` returning Content-Type header ↵yuuji.yaginuma2019-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | as it is Since #35709, `Response#conten_type` returns only MIME type correctly. It is a documented behavior that this method only returns MIME type, so this change seems appropriate. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/actionpack/lib/action_dispatch/http/response.rb#L245-L249 But unfortunately, some users expect this method to return all Content-Type that does not contain charset. This seems to be breaking changes. We can change this behavior with the deprecate cycle. But, in that case, a method needs that include Content-Type with additional parameters. And that method name is probably the `content_type` seems to properly. So I changed the new behavior to more appropriate `media_type` method. And `Response#content_type` changed (as the method name) to return Content-Type header as it is. Fixes #35709. [Rafael Mendonça França & Yuuji Yaginuma ]
* Document that `format.any` can match all formatsDaniel Schierbeck2019-01-161-0/+8
| | | I had to dig around the code to discover this, since I had a use case for the behavior.
* Merge pull request #33718 from kddeisz/permit-listMatthew Draper2018-08-291-1/+1
|\ | | | | Finish converting whitelist and blacklist references
| * Convert over the rest of the whitelist referencesKevin Deisz2018-08-241-1/+1
| |
* | Format respond_to method as code in doc [ci skip]Rob Zolkos2018-08-251-1/+1
|/ | | | | This updates the `respond_to` method to be code formatted rather than plain text (as it refers to the method)
* Raises exception when respond_to called multiple times in incompatible wayPatrick Toomey2018-07-301-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nesting respond_to calls can lead to unexpected behavior, so it should be avoided. Currently, the first respond_to format match sets the content-type for the resulting response. But, if a nested respond_to occurs, it is possible to match on a different format. For example: respond_to do |outer_type| outer_type.js do respond_to do |inner_type| inner_type.html { render body: "HTML" } end end end Browsers will often include */* in their Accept headers. In the above example, such a request would result in the outer_type.js match setting the content- type of the response to text/javascript, while the inner_type.html match will cause the actual response to return "HTML". This change tries to minimize potential breakage by only raising an exception if the nested respond_to calls are in conflict with each other. So, something like the following example would not raise an exception: respond_to do |outer_type| outer_type.js do respond_to do |inner_type| inner_type.js { render body: "JS" } end end end While the above is nested, it doesn't affect the content-type of the response.
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* 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.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Small grammar fixJon Moss2017-03-221-1/+1
| | | | [ci skip]
* [docs] fix ActionController documentationHrvoje Šimić2017-03-121-2/+2
| | | | [ci skip]
* Add three new rubocop rulesRafael Mendonça França2016-08-161-2/+2
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Render default template if block doesn't renderJustin Coyne2016-02-251-1/+1
| | | | | | | | When a `respond_to` collector doesn't have a response, then a `:no_content` response should be rendered. This brings the default rendering behavior introduced by https://github.com/rails/rails/issues/19036 to controller methods employing `respond_to`
* remove doc reference to ActionController::MimeResponds#respond_tosealocal2016-01-201-3/+0
|
* document simple example of ActionController::MimeResponds#respond_tosealocal2016-01-201-1/+9
|
* fix rdoc markup [ci skip]yuuji.yaginuma2015-10-251-4/+4
|
* Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-3/+3
| | | | | | | | | | | | | | | | | 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
* swap upcase and to_symAaron Patterson2015-09-211-1/+1
|
* stop calling deprecated methodsAaron Patterson2015-09-211-3/+3
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* push content_type assigment in to metalAaron Patterson2015-09-081-1/+1
| | | | | everything above metal really doesn't care about setting the content type, so lets rearrange these methods to be in metal.
* only call self.content_type= when there is a responseAaron Patterson2015-08-261-0/+1
| | | | | Apparently the AbstractController (whatever "abstract" means) is expected to work without a request and response.
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-4/+4
| | | | | | | | | This will silence deprecation warnings. Most of the test can be changed from `render :text` to render `:plain` or `render :body` right away. However, there are some tests that needed to be fixed by hand as they actually assert the default Content-Type returned from `render :body`.
* Provide friendlier access to request variantsGeorge Claghorn2015-03-241-6/+7
| | | | Closes #18933.
* Remove unused requireCarlos Antonio da Silva2015-01-041-1/+0
| | | | | This was used by the respond_to/respond_with implementation on this file, which is now extracted to the responders gem.
* Remove respond_to/respond_with placeholder methodsCarlos Antonio da Silva2015-01-041-20/+0
| | | | This functionality has been extracted to the responders gem.
* Removed documentation that still mentioned using respond_with in placeRobert Evans2014-11-051-16/+4
| | | | | of respond_to. respond_with was moved into the responders gem and deprecated inside rails, so there is no need to mention it within rails itself.
* Merge pull request #17302 from ↵Rafael Mendonça França2014-10-181-2/+2
| | | | | | claudiob/replace-slower-block-call-with-faster-yield Replace (slower) block.call with (faster) yield
* Revert "Replace (slower) block.call with (faster) yield"Zachary Scott2014-10-181-2/+2
| | | | This reverts commit 0ab075e75f58bf403f7ebe20546c7005f35db1f6.
* Replace (slower) block.call with (faster) yieldclaudiob2014-10-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Performance optimization: `yield` with an implicit `block` is faster than `block.call`. See http://youtu.be/fGFM_UrSp70?t=10m35s and the following benchmark: ```ruby require 'benchmark/ips' def fast yield end def slow(&block) block.call end Benchmark.ips do |x| x.report('fast') { fast{} } x.report('slow') { slow{} } end # => fast 154095 i/100ms # => slow 71454 i/100ms # => # => fast 7511067.8 (±5.0%) i/s - 37445085 in 4.999660s # => slow 1227576.9 (±6.8%) i/s - 6145044 in 5.028356s ```
* `responders` 1.x won't do it. Told you to RTFM for details!Godfrey Chan2014-08-171-3/+6
|
* The gem is called 'responders'Godfrey Chan2014-08-171-2/+2
|
* Raise a more helpful error for people who are using these extracted featuresGodfrey Chan2014-08-171-1/+16
|
* Move respond_with to the responders gemJosé Valim2014-08-171-231/+3
| | | | | | | | respond_with (and consequently the class-level respond_to) are being removed from Rails. Instead of moving it to a 3rd library, the functionality will be moved to responders gem (at github.com/plataformatec/responders) which already provides some responders extensions.
* [ci skip] /javascript/ ~> JavaScriptAditya Kapoor2014-06-171-3/+3
|
* No variant should also be picked up by variant.any if variant.none is not ↵David Heinemeier Hansson2014-02-131-1/+1
| | | | defined (just like any other variant)
* Variant negotiationLukasz Strzalkowski2014-02-131-8/+20
| | | | | | | | | | | | | | Allow setting `request.variant` as an array - an order in which they will be rendered. For example: request.variant = [:tablet, :phone] respond_to do |format| format.html.none format.html.phone # this gets rendered end
* Add any/all support for variantsŁukasz Strzałkowski2013-12-261-27/+54
| | | | | | | | | | | | | | | | | | | | Like `format.any`, you can do the same with variants. It works for both inline: respond_to do |format| format.html.any { render text: "any" } format.html.phone { render text: "phone" } end and block syntax: respond_to do |format| format.html do |variant| variant.any(:tablet, :phablet){ render text: "any" } variant.phone { render text: "phone" } end end
* Some assorted fixes for the 4.1 release notes:Godfrey Chan2013-12-171-1/+1
| | | | | | | | | | | * Added release notes for secrets.yml and mentioned it in the highlights * Added release notes for Mailer previews and mentioned it in the highlights * Added release notes for Module#concerning * Removed mention for AV extraction from the highlights * Rearranged the major features to put highlighted features first * Various improvements and typo fixes [ci skip]
* Variants inline syntax documentation [ci skip]Łukasz Strzałkowski2013-12-121-0/+9
| | | | | | * Extend method documentation * Mention it in actionpack/CHANGELOG * Update release notes
* Inline variants syntaxŁukasz Strzałkowski2013-12-101-2/+24
| | | | | | | | | | | | | | | | | | | | | | | In most cases, when setting variant specific code, you're not sharing any code within format. Inline syntax can vastly simplify defining variants in those situations: respond_to do |format| format.js { render "trash" } format.html do |variant| variant.phone { redirect_to progress_path } variant.none { render "trash" } end end Becomes: respond_to do |format| format.js { render "trash" } format.html.phone { redirect_to progress_path } format.html.none { render "trash" } end
* Simplify @responses hash initializationŁukasz Strzałkowski2013-12-101-1/+2
| | | | | | | | | | | | | @responses hash needs to be initialized with mime types that we get from Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as value. This need to happen before content negotiation. Before that, it was looping though mime types and executing mime-type-generated method inside collector (see AbstractController::Collector#generate_method_for_mime). That approach resulted in 2 unnecessary method calls for each mime type collected by Collector#collect_mimes_from_class_level. Now hash is initialized in place, without usage of Collector#custom method.
* Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a ↵David Heinemeier Hansson2013-12-081-15/+9
| | | | | | | little more work! This reverts commit 186161148a189839a1e0924043f068a8d155ce69, reversing changes made to cad9eb178ea5eec0e27d74e93518f4ed34e2f997.
* Inline variants syntaxŁukasz Strzałkowski2013-12-081-8/+14
| | | | | | | | | | | | | | | | | | | | | | | In most cases, when setting variant specific code, you're not sharing any code within format. Inline syntax can vastly simplify defining variants in those sitiations: respond_to do |format| format.js { render "trash" } format.html do |variant| variant.phone { redirect_to progress_path } variant.none { render "trash" } end end ` Becomes: respond_to do |format| format.js { render "trash" } format.html.phone { redirect_to progress_path } format.html.none { render "trash" } end
* Simplify @responses hash initializationŁukasz Strzałkowski2013-12-081-1/+1
| | | | | | | | | | | | | @responses hash needs to be initialized with mime types that we get from Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as value. This need to happen before content negotiation. Before that, it was looping though mime types and executing mime-type-generated method inside collector (see AbstractController::Collector#generate_method_for_mime). That approach resulted in 2 unnecessary method calls for each mime type collected by Collector#collect_mimes_from_class_level. Now hash is initialized in place, without usage of Collector#custom method.
* Variants can be declared without a block to signify their presence in the ↵David Heinemeier Hansson2013-12-071-1/+3
| | | | controller
* Allow code execution in case no variant has been set with variant.noneDavid Heinemeier Hansson2013-12-071-4/+5
|
* Improve a couple exception messages related to variants and mime typesCarlos Antonio da Silva2013-12-031-2/+4
| | | | | Avoid one-liner conditionals when they are too big. Avoid concatenating strings to build error messages. Improve messages a bit.
* Add nodoc to added VariantFilter classCarlos Antonio da Silva2013-12-031-3/+3
|