aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/mime_type.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
* processing image/* is an odditity because there isNeeraj Singh2010-11-251-1/+1
| | | | | | a test case which expects image/* to not to be expanded. So I am leaving image/* as it is and process only text/* and application/*
* unregister method implementation and testNeeraj Singh2010-11-251-0/+12
|
* remove select, collect and then inject withNeeraj Singh2010-11-221-1/+1
| | | | | | something better Signed-off-by: José Valim <jose.valim@gmail.com>
* string include method is 10x faster than creatingNeeraj Singh2010-11-221-1/+1
| | | | | | a new regex object every single time Signed-off-by: José Valim <jose.valim@gmail.com>
* Compile regex only onceNeeraj Singh2010-11-221-3/+5
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* implement code that handles text/*, appplication/*,Neeraj Singh2010-11-221-1/+16
| | | | | | and image/* Signed-off-by: José Valim <jose.valim@gmail.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-10/+10
| | | | 's/[ \t]*$//' -i {} \;)
* Fix a bunch of minor spelling mistakesEvgeniy Dolzhenko2010-06-111-1/+1
|
* adds missing requires for Object#blank? and Object#present?Xavier Noria2010-03-281-0/+1
|
* Clean up Mime::Type and remove deprecated stuff (from 2.3).José Valim2010-03-201-7/+1
|
* Make sure evalled method knows where it came fromYehuda Katz2009-12-291-2/+2
|
* Silence some trivial warnings: shadowed local vars, indentation mismatchesJeremy Kemper2009-12-281-1/+1
|
* Reduce TextTemplate cost for simple casesYehuda Katz2009-10-281-0/+1
|
* Avoid super in define_method for RubiniusYehuda Katz2009-10-091-1/+6
|
* Remove last TODO.José Valim2009-07-291-1/+1
| | | | Signed-off-by: Yehuda Katz <wycats@gmail.com>