aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/mime_type.rb
Commit message (Collapse)AuthorAgeFilesLines
* Delete needless `require 'active_support/deprecation'`yui-knk2015-10-201-1/+0
| | | | | When `require 'active_support/rails'`, 'active_support/deprecation' is automatically loaded.
* Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-38/+36
| | | | | | | | | | | | | | | | | 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
* Fix deprecated mime types via constantsamitkumarsuroliya2015-09-251-5/+5
| | | Accessing mime types via constants is deprecated. Now, we are using `Mime::Type[:JSON]` instead of `Mime::JSON`
* drop array allocations on Mime::Type#=~Aaron Patterson2015-09-211-3/+1
| | | | | Synonyms are always a list of strings, and we have access to the internal string representation, so we can avoid allocating new arrays.
* remove another `blank?` callAaron Patterson2015-09-211-1/+1
|
* remove html_types setAaron Patterson2015-09-211-6/+2
| | | | Now that `all` has it's own object, we don't need the html_types Set.
* introduce an `All` mime typeAaron Patterson2015-09-211-0/+6
| | | | | This class gives us the `all?` predicate method that returns true without hitting method missing
* remove `blank?` calls on `==`Aaron Patterson2015-09-211-1/+1
| | | | | | | | | Since Mime::Type implements `method_missing`, and `blank?` triggers it's positive branch: https://github.com/rails/rails/blob/f9dda1567ea8d5b27bd9d66ac5a8b43dc67a6b7e/actionpack/lib/action_dispatch/http/mime_type.rb#L342 We should stop calling `blank?`.
* change inheritance to compositionAaron Patterson2015-09-211-14/+24
| | | | | | Changes `Mimes` to compose a set rather than inherit from array. With this change we don't need to define as many methods, so ISEQ memory is saved. Also it is clear which methods break the set cache.
* stop calling deprecated methodsAaron Patterson2015-09-211-2/+2
| | | | | We should be asking the mime type method for the mime objects rather than via const lookup
* deprecate accessing mime types via constantsAaron Patterson2015-09-211-5/+53
| | | | | | | | | | | | | | | | | | We don't want to manage a list of constants on `Mime::`. Managing constants is strange because it will break method caches, not to mention looking up by a constant could cause troubles. For example suppose there is a top level constant `HTML`, but nobody registers the HTML mime type and someone accesses `Mime::HTML`. Instead of getting an error about how the mime type doesn't exist, instead you'll get the top level constant. So, instead of directly accessing the constants, change this: Mime::HTML To this: Mime::Type[:HTML]
* cache the new type object on the stackAaron Patterson2015-09-211-2/+2
| | | | Now we don't have to look it up with a `const_get`.
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-1/+1
| | | | | | | | | 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`.
* added description instead of remove usage [ci skip]Julio Lopez2015-07-111-1/+1
|
* fix method name in mime type example. `Mime::Type.[]` doesn't exist. [ci skip]yuuji.yaginuma2015-02-231-1/+1
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* [ci skip]Correct variables in the sample codesuginoy2014-09-101-2/+2
|
* Replace trivial regexp with string or index, twice as fastKelley Reynolds2014-03-281-1/+1
|
* Move the null mime type to request.formatCarlos Antonio da Silva2013-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TLDR: always return an object that responds to the query methods from request.format, and do not touch Mime::Type[] lookup to avoid bugs. --- Long version: The initial issue was about being able to do checks like request.format.html? for request with an unknown format, where request.format would be nil. This is where the issue came from at first in #7837 and #8085 (merged in cba05887dc3b56a46a9fe2779b6b228880b49622), but the implementation went down the path of adding this to the mime type lookup logic. This unfortunately introduced subtle bugs, for instance in the merged commit a test related to send_file had to be changed to accomodate the introduction of the NullType. Later another bug was found in #13064, related to the content-type being shown as #<Mime::NullType:...> for templates with localized extensions but no format included. This one was fixed in #13133, merged in 43962d6ec50f918c9970bd3cd4b6ee5c7f7426ed. Besides that, custom handlers were not receiving the proper template formats anymore when passing through the rendering process, because of the NullType addition. That was found while migrating an application from 3.2 to 4.0 that uses the Markerb gem (a custom handler that generates both text and html emails from a markdown template). --- This changes the implementation moving away from returning this null object from the mime lookup, and still fixes the initial issue where request.format.zomg? would raise an exception for unknown formats due to request.format being nil.
* remove nil in NullType#ref.Angelo capilleri2013-12-041-3/+1
| | | | | Return Nil is implicit in a method and this syntax is used in the others classes
* Convert Mime::NullType in a singletonGuillermo Iguaran2013-12-031-1/+4
|
* Remove deprecated cattr_* requiresGenadi Samokovarov2013-12-031-1/+1
|
* Fix undefined method `ref' for nil:NilClass for bad accept headersStephen Becker IV2013-06-191-1/+1
|
* Remove Mime::Type#verify_request? and Mime::Type.browser_generated_types ↵kennyj2013-06-021-16/+0
| | | | were deprecated.
* Return nil for Mime::NullType#refAndrew White2013-04-101-0/+4
|
* Reverts rendering behavior when format is unknownGrzegorz Świrski2013-04-101-1/+5
| | | | | | | | | If a request has unknown format (eg. /foo.bar), the renderer fallbacks to default format. This patch reverts Rails 3.2 behavior after c2267db commit. Fixes issue #9654.
* Mark unused variables and make some style fixesAgis Anastasopoulos2013-04-081-2/+2
| | | | It'd be a nice convention to mark the unused variables like this, now that Ruby 2 will issue no warnings for such vars being unused.
* return Mime::NullType if format is unknownAngelo Capilleri2012-12-221-1/+12
| | | | | | | | | | If a request has an unknown format, the methods html?, xml?, json? ...etc not raise an Exception. This patch add a class Mime::NullType, that is returned when request.format is unknown and it responds false to the methods that ends with '?' and true to 'nil?'. It refers to #7837, this issue is considered a improvement not a bug.
* implement to_a and to_ary so that the Array() call in template.rb willAaron Patterson2012-11-091-9/+14
| | | | | | | | | | | | | | | | not raise so many exceptions: https://github.com/rails/rails/blob/master/actionpack/lib/action_view/template.rb#L126 irb(main):001:0> class Foo; def method_missing(*args); super; end end => nil irb(main):002:0> $DEBUG = true => true irb(main):003:0> Array(Foo.new) Exception `NoMethodError' at (irb):1 - undefined method `to_ary' for #<Foo:0x007f854390e488> Exception `NoMethodError' at (irb):1 - undefined method `to_a' for #<Foo:0x007f854390e488> => [#<Foo:0x007f854390e488>] irb(main):004:0>
* 1.9 hash syntax changes to docsAvnerCohen2012-10-311-2/+2
|
* depreacte unused Mime::Type#verify_request? and ↵grosser2012-09-241-1/+6
| | | | Mime::Type.browser_generated_types
* Fixed missing requireIlya Vorontsov2012-09-081-0/+1
| | | | | | | Missing require caused fail of guide generation (in action_dispatch/http/mime_type, line 295, undefined method `ends_with` for "to_ary":String) With this fix guides were normally generated
* Refactor `Mime::Type`Aleksey Magusev2012-09-051-84/+93
| | | | | | | | | | | `parse` method performance improvements - ~27-33%: accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, , pronto/1.00.00, sslvpn/1.00.00.00, */*" Benchmark.measure{ 1_000_0.times { Mime::Type.parse(accept) }} old: 1.430000 0.000000 1.430000 ( 1.440977) new: 0.920000 0.000000 0.920000 ( 0.921813)
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* Prevent conflict between mime types and Object methodsMircea Pricop2012-07-061-1/+12
| | | | | | | | | | | | | | | | | | | | | | | Assuming the type ":touch", Collector.new was calling send(:touch), which instead of triggering method_missing and generating a new collector method, actually invoked the private method `touch` inherited from Object. By generating the method for each mime type as it is registered, the private methods on Object can never be reached by `send`, because the `Collector` will have them before `send` is called on it. To do this, a callback mechanism was added to Mime::Type This allows someone to add a callback for whenever a new mime type is registered. The callback then gets called with the new mime as a parameter. This is then used in AbstractController::Collector to generate new collector methods after each mime is registered.
* add Mime.fetch so we can have default mime typesAaron Patterson2012-07-031-0/+5
|
* both string and sumbol will be interpolated as string no need to convert to_sganesh2012-06-111-3/+3
|
* Fix rdoc formatting in Mime::TypeMark Rushakoff2012-04-291-5/+5
|
* Fix example action dispatch in mime typeAlexey Vakhov2012-04-071-1/+1
|
* Added parsing of arbitrary media type parameters.Steve Klabnik2012-03-051-3/+3
| | | | | | Based on #4918. Related to #4127.
* Correctly handle single media with q value. Fixes #736.Scott W. Bradley2012-02-061-1/+3
|
* Allow symbols to be passed for extension aliasesJustin Campbell2011-12-171-1/+1
|
* Implement Mime::Type#respond_to? (consistently with #method_missing)Evgeniy Dolzhenko2011-09-251-0/+4
|
* Remove extra white spaces on ActionPack docs.Sebastian Martinez2011-05-231-2/+2
|
* Use Mime::Type references.José Valim2011-02-081-1/+5
|
* Merge branch 'master' of git://github.com/lifo/docrailsXavier Noria2010-12-051-2/+2
|\
| * Fix mime type doc typosCarlos Antonio da Silva2010-12-041-2/+2
| |
* | Fix tests on 1.9.2.José Valim2010-11-281-6/+9
| |
* | trailing star mimes should respect the order in which mime types are defined.José Valim2010-11-281-7/+11
|/
* process text/* if it appears in the middle ofNeeraj Singh2010-11-251-1/+5
| | | | HTTP_ACCEPT parameter