aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http
Commit message (Collapse)AuthorAgeFilesLines
* Fix method signature of `parse_query` to match rackeileencodes2015-04-061-1/+1
| | | | | | | Recently rack was changed to have a second argument on the `parse_query` method (in rack/rack#781). Rails relies on this and it's `parse_query` method was complaining about missing the second argument. I changed the arguments to `*` so we don't have this issue in the future.
* Add ActiveSupport::ArrayInquirer and Array#inquiryGeorge Claghorn2015-03-241-27/+2
| | | | | | | | | | | | | | | | | | | | | | Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its string-like contents. For example, `request.variant` returns an `ArrayInquirer` object. To check a request's variants, you can call: request.variant.phone? request.variant.any?(:phone, :tablet) ...instead of: request.variant.include?(:phone) request.variant.any? { |v| v.in?([:phone, :tablet]) } `Array#inquiry` is a shortcut for wrapping the receiving array in an `ArrayInquirer`: pets = [:cat, :dog] pets.cat? # => true pets.ferret? # => false pets.any?(:cat, :ferret} # => true
* Provide friendlier access to request variantsGeorge Claghorn2015-03-241-7/+34
| | | | Closes #18933.
* Fix handling of empty X_FORWARDED_HOST header.adam2015-03-201-1/+1
| | | | | | Previously, an empty X_FORWARDED_HOST header would cause Actiondispatch::Http:URL.raw_host_with_port to return nil, causing Actiondispatch::Http:URL.host to raise a NoMethodError.
* Merge pull request #19215 from ↵Sean Griffin2015-03-051-3/+1
|\ | | | | | | | | gsamokovarov/revert-ruby-2-2-0-kwarg-crash-workarounds Revert work arounds for upstream Ruby 2.2.0 kwargs bug
| * Revert work arounds for upstream Ruby 2.2.0 kwargs bugGenadi Samokovarov2015-03-051-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug caused a segfault and you can find more info about it at: https://bugs.ruby-lang.org/issues/10685. We did a couple of work arounds, but 2.2.1 rolled out and those aren't needed anymore. Here are the reverted commits: - Revert "Work around for upstream Ruby bug #10685", commit 707a433870e9e06af688f85a4aedc64a90791a64. - Revert "Fix segmentation fault in ActionPack tests", commit 22e0a22d5f98e162290d9820891d8191e720ad3b. I'm also bumping the Ruby version check to 2.2.1 to prevent future segfaults.
* | nodoc filtered_location [ci skip]Sushruth Sivaramakrishnan2015-03-051-1/+1
|/
* Merge pull request #19147 from gsamokovarov/work-around-ruby-10695Eileen M. Uchitelle2015-03-021-1/+3
|\ | | | | Work around for upstream Ruby bug #10685
| * Work around for upstream Ruby bug #10685Genadi Samokovarov2015-03-011-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In f6e293ec54f02f83cdb37502bea117f66f87bcae we avoided a segfault in the tests, however I think we should try to avoid the crash, as it may happen in user code as well. Here is what I distiled the bug down to: ```ruby # Rails case - works on 2.0, 2.1; crashes on 2.2 require 'action_dispatch' ActionDispatch::Response.new(200, "Content-Type" => "text/xml") # General case - works on 2.0, 2.1; crashes on 2.2 def foo(optional = {}, default_argument: nil) end foo('quux' => 'bar') ```
* | ask the routes objects for its Rack env keyAaron Patterson2015-03-021-1/+1
| | | | | | | | | | | | this centralizes the logic for determining the script name key and drops object allocations when calling `engine_script_name` (which is called on each `url_for`).
* | drop string allocations per model url_for call in viewsAaron Patterson2015-03-011-1/+1
|/ | | | | | | | | | | | ```ruby article = Article.new.tap(&:save!) view.url_for article result = ObjectSpace::AllocationTracer.trace do 3000.times { view.url_for article } end p ObjectSpace::AllocationTracer.allocated_count_table[:T_STRING] / 3000 ```
* Fix default headers in test responsesJeremy Kemper2015-02-251-5/+3
| | | | | | | Fixes regression in #18423. Merge default headers for new responses, but don't merge when creating a response from the last session request. hat tip @senny :heart:
* fix method name in mime type example. `Mime::Type.[]` doesn't exist. [ci skip]yuuji.yaginuma2015-02-231-1/+1
|
* Prefer request_id over uuid and test the aliasRafael Mendonça França2015-02-201-4/+4
|
* Aliased the ActionDispatch::Request#uuid method with ↵David Ilizarov2015-02-201-0/+2
| | | | ActionDispatch::Request#request_id
* Extract `Date` header to string constant in Http Response, similar to other ↵Vipul A M2015-01-141-3/+4
| | | | headers
* Remove unneeded requiresRafael Mendonça França2015-01-041-1/+0
| | | | These requires were added only to change deprecation message
* Remove deprecated `ActionDispatch::Response#to_ary`Rafael Mendonça França2015-01-041-15/+0
|
* Remove deprecated `ActionDispatch::Request#deep_munge`Rafael Mendonça França2015-01-041-9/+0
|
* Remove deprecated `ActionDispatch::Http::Parameters#symbolized_path_parameters`Rafael Mendonça França2015-01-041-8/+0
|
* stop referencing `env` in url_forAaron Patterson2014-12-301-0/+4
| | | | | encapsulate env in the request so that we can eventually move away from the env hash
* use methods on the request rather than direct hash accessAaron Patterson2014-12-301-0/+8
| | | | this will help decouple us from using the rack env hash
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2014-12-201-0/+109
|\
| * Add docs for ActionDispatch::Http::URL methodsclaudiob2014-12-181-0/+109
| | | | | | | | | | | | | | | | | | | | Add docs for `extract_domain`, `extract_subdomains`, `extract_subdomain`. Add doc examples for `url`, `protocol`, `raw_host_with_port`, `host`, `host_with_port`, `port`, `standard_port`, `standard_port?`, `optional_port`, `port_string`. [ci skip]
* | allow reseting of request variantsTimo Schilling2014-12-161-1/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | The current implementation of `variants=` don't allow a resetting to nil, wich is the default value. This results in the following code smell: ```ruby case request.user_agent when /iPhone/ request.variants = :phone when /iPad/ request.variants = :ipad end ``` With the ability to reset variants to nil, it could be: ```ruby request.variants = case request.user_agent when /iPhone/ :phone when /iPad/ :ipad end ```
* ParameterFilter shouldn't try to dup symbol keysNate Berkopec2014-12-131-1/+1
|
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Anchor should not be appended when set to nil/false.Guo Xiang Tan2014-11-231-1/+3
| | | | Fixes https://github.com/rails/rails/issues/17714.
* edit pass over all warningsXavier Noria2014-10-283-5/+5
| | | | | | | | | | | | | | | This patch uniformizes warning messages. I used the most common style already present in the code base: * Capitalize the first word. * End the message with a full stop. * "Rails 5" instead of "Rails 5.0". * Backticks for method names and inline code. Also, converted a few long strings into the new heredoc convention.
* let's warn with heredocsXavier Noria2014-10-281-1/+7
| | | | | | | | | | | | The current style for warning messages without newlines uses concatenation of string literals with manual trailing spaces where needed. Heredocs have better readability, and with `squish` we can still produce a single line. This is a similar use case to the one that motivated defining `strip_heredoc`, heredocs are super clean.
* remove duplicate method (_status_code) in action_dispatchAbdelkader Boudih2014-10-191-3/+0
|
* Make _status_code methods nodocPrathamesh Sonpatki2014-10-191-1/+1
| | | | | - Also one minor change for documenting url_for method in ActionController::Metal. [ci skip]
* Request#check_method no longer breaks when :en is not available localeStefan Henzen2014-10-091-1/+1
| | | | | | | | Request#check_method would use to_sentence(locale: :en), which breaks when I18n.available_locales does not include :en and I18n.enforce_available_locales is true (default). Inlined to_sentence functionality to solve this.
* Rescue Rack::Utils::ParameterTypeError instead of TypeErrorYuki Nishijima2014-09-131-2/+2
| | | | | | | | As of rack/rack@167b6480235ff00ed5f355698bf00ec2f250f72e, Rack raises Rack::Utils::ParameterTypeError which inherits TypeError. In terms of the behavior, Rescuing TypeError still works but this method shouldn't rescue if TypeError is raised for other reasons.
* [ci skip]Correct variables in the sample codesuginoy2014-09-101-2/+2
|
* Add support for Rack::ContentLength middelwareJavan Makhmali2014-09-061-0/+4
|
* Deprecate implicit AD::Response splatting and Array conversionJeremy Kemper2014-09-061-2/+13
|
* Avoid duplicating routes for HEAD requests.Guo Xiang Tan2014-08-211-0/+6
| | | | | | | | Follow up to rails#15321 Instead of duplicating the routes, we will first match the HEAD request to HEAD routes. If no match is found, we will then map the HEAD request to GET routes.
* Protect against error when parsing parameters with Bad RequestRafael Mendonça França2014-08-191-2/+2
| | | | Related with #11795.
* use 'based on' instead of 'based off' [ci skip]Akshay Vishnoi2014-08-121-1/+1
|
* Realign assignments :scissors:Carlos Antonio da Silva2014-07-311-5/+5
|
* Do not reassign variable when mutation is happeningCarlos Antonio da Silva2014-07-311-8/+5
| | | | | These methods mutate the path variable/argument so there is no need to reassign it every time.
* Only concatenate path if it was given rather than converting blindlyCarlos Antonio da Silva2014-07-311-1/+1
|
* Rename variable to better show its intentCarlos Antonio da Silva2014-07-311-12/+12
|
* Simplify conditionalCarlos Antonio da Silva2014-07-311-3/+2
|
* Push options check up so we can simplify internal methodsCarlos Antonio da Silva2014-07-311-13/+10
|
* LOCALHOST definition should match any 127.0.0.0/8 addressEarl J St Sauver2014-07-181-1/+1
| | | | | | | | | | | | | | | The entire 127.0.0.0/8 range is assigned to the loopback address, not only 127.0.0.0/24. This patch allows ActionDispatch::Request::LOCALHOST to match any IPv4 127.0.0.0/8 loopback address. The only place that the #local? method was previously under test was in the show_expectations_test.rb file. I don't particularly like that that's implicitly where this code is under test, and I feel like I should move some of that testing code into the test/dispatch/request_test.rb file, but I wanted some feedback first. Credit goes to @sriedel for discovering the issue and adding the patch.
* use a strategy object for generating urls in named helpersAaron Patterson2014-07-171-8/+13
| | | | | | since we know that the route should be a path or fully qualified, we can pass a strategy object that handles generation. This allows us to eliminate an "if only_path" branch when generating urls.
* extract path building to a methodAaron Patterson2014-07-161-9/+11
|
* break out path building logic to methodsAaron Patterson2014-07-161-14/+22
|