aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request_test.rb
Commit message (Collapse)AuthorAgeFilesLines
...
* Avoid duplicating routes for HEAD requests.Guo Xiang Tan2014-08-211-0/+12
| | | | | | | | 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-0/+25
| | | | Related with #11795.
* [ci skip] fix spelling of overrideAkshay Vishnoi2014-08-131-1/+1
|
* Merge pull request #16098 from tgxworld/fixes_to_request_testRafael Mendonça França2014-07-181-22/+14
|\ | | | | Fixes to request method test.
| * Remove redundant test.Guo Xiang Tan2014-07-181-11/+0
| | | | | | | | | | | | | | | | Since we're stubbing the request, the test is actually just asserting that `@method = env['REQUEST_METHOD']`. In order to the test against the methodoverride middleware, we should test it against an actual request. However, Rack is already covering this scenario so we can remove this test.
| * Fix duplicated test.Guo Xiang Tan2014-07-181-2/+6
| | | | | | | | | | There is already another test covering Request#request_method. This test should cover Request#method.
| * Update test to clearly reflect what it is testing for.Guo Xiang Tan2014-07-181-5/+7
| |
| * Update outdated test.Guo Xiang Tan2014-07-181-6/+3
| | | | | | | | | | The current test is asserting against an outdated version of Request#method where HEAD requests are treated as GET requests.
* | Add CHANGELOG for #14886Arthur Neves2014-07-181-1/+1
| | | | | | | | | | | | | | Also cleanup test a bit [related #14886] [related #14743]
* | LOCALHOST definition should match any 127.0.0.0/8 addressEarl J St Sauver2014-07-181-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #13999 from jamox/update_rackAaron Patterson2014-07-081-6/+12
|\ \ | |/ |/| This updates rails to use edge rack
| * Upgraded rackJarmo Isotalo2014-05-191-6/+12
| | | | | | | | | | | | | | | | As Rack has some non backwards compatible changes added required modifications to keep behaviour in rails close to same as before. Also modified generators to include rack/rack for not yet released version of rack
* | Fix typoRafael Mendonça França2014-07-021-1/+1
| |
* | Avoid hard-coded value in test setup/teardown.Zuhao Wan2014-06-051-1/+2
|/
* Merge pull request #12651 from cespare/ipv6-remote-ip-fixesRafael Mendonça França2014-05-011-1/+4
|\ | | | | | | | | | | | | Make remote_ip detection properly handle private IPv6 addresses Conflicts: actionpack/CHANGELOG.md
| * Make remote_ip detection properly handle private IPv6 addressesCaleb Spare2013-10-261-1/+4
| | | | | | | | Fixes #12638.
* | Refactor tests from BaseRackTest into BaseRequestTestZachary Scott2014-03-011-179/+386
| |
* | Check if variant array contains only symbolsŁukasz Strzałkowski2014-02-131-0/+8
| |
* | Variant negotiationLukasz Strzalkowski2014-02-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Fix assertions for testing unknown formats using Mime::NullTypeCarlos Antonio da Silva2013-12-191-5/+5
| |
* | Action Pack VariantsŁukasz Strzałkowski2013-12-041-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, variants in the templates will be picked up if a variant is set and there's a match. The format will be: app/views/projects/show.html.erb app/views/projects/show.html+tablet.erb app/views/projects/show.html+phone.erb If request.variant = :tablet is set, we'll automatically be rendering the html+tablet template. In the controller, we can also tailer to the variants with this syntax: class ProjectsController < ActionController::Base def show respond_to do |format| format.html do |html| @stars = @project.stars html.tablet { @notifications = @project.notifications } html.phone { @chat_heads = @project.chat_heads } end format.js format.atom end end end The variant itself is nil by default, but can be set in before filters, like so: class ApplicationController < ActionController::Base before_action do if request.user_agent =~ /iPad/ request.variant = :tablet end end end This is modeled loosely on custom mime types, but it's specifically not intended to be used together. If you're going to make a custom mime type, you don't need a variant. Variants are for variations on a single mime types.
* | Add regression test for IpSpoofAttackError issueAlvaro Redondo2013-09-031-0/+8
|/ | | | See #10780
* Fix formats on xhr requests when HTTP_ACCEPT is empty stringmaximerety2013-03-041-0/+5
| | | | | | Fix ActionDispatch::Request#formats on xhr requests when HTTP_ACCEPT header is empty string. About issue #7774, same fix as in commit bebb02f but for xhr requests.
* Merge pull request #8704 from senny/remove_regexp_global_from_url_forAaron Patterson2013-02-141-0/+3
|\ | | | | replace regexp global in #url_for
| * replace regexp global in #url_forYves Senn2013-01-161-0/+3
| |
* | Fix ActionDispatch::Request#formats when HTTP_ACCEPT header is empty stringKonstantin Papkovskiy2013-01-171-0/+4
|/
* adding regression test in master for #8631Aditya Sanghi2013-01-161-0/+21
|
* Restore original remote_ip algorithm.Andre Arko2013-01-021-58/+44
| | | | | | | | | | | Proxy servers add X-Forwarded-For headers, resulting in a list of IPs. We remove trusted IP values, and then take the last given value, assuming that it is the most likely to be the correct, unfaked value. See [1] for a very thorough discussion of why that is the best option we have at the moment. [1]: http://blog.gingerlime.com/2012/rails-ip-spoofing-vulnerabilities-and-protection/ Fixes #7979
* return Mime::NullType if format is unknownAngelo Capilleri2012-12-221-1/+10
| | | | | | | | | | 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.
* Fix rewinding in ActionDispatch::Request#raw_postMatt Venables2012-12-111-0/+7
| | | | | | | | | If env['RAW_POST_DATA'] is nil, #raw_post will attempt to set it to the result of #body (which will return env['rack.input'] if env['RAW_POST_DATA'] is nil). #raw_post will then attempt to rewind the result of another call to #body. Since env['RAW_POST_DATA'] has already been set, the result of #body is not env['rack.input'] anymore. This causes env['rack.input'] to never be rewound.
* Correct the use of params options when given to url_forCarlos Antonio da Silva2012-11-191-9/+3
| | | | Merge url for tests and add changelog entry for #8233.
* Fix issue with params in url_fortumayun2012-11-191-0/+8
| | | | | | With a "params" argument, the following error is raised: undefined method `reject!` for "":String
* Refactor request tests, remove #with_set methodCarlos Antonio da Silva2012-11-191-8/+3
|
* Revert "if format is unknown NullMimeTypeObject is returned"Guillermo Iguaran2012-10-311-11/+1
| | | | This reverts commit a8560fa361958b33d76e4468eb5c07d82a20196e.
* if format is unknown NullMimeTypeObject is returnedAngelo capilleri2012-10-311-1/+11
| | | | | | | | | | If a unknown format is passed in a request, the methods html?, xml?, json? ...etc Nil Exception. This patch add a class NullMimeTypeObject, that is returned when request.format is unknown and it responds false to the methods that ends with '?'. It refers to #7837, not fixes because it's not considered a improvement not a bug.
* give access to the original exception raised in case of a parse errorAaron Patterson2012-10-251-0/+14
|
* do not lose backtrace information from the raised exceptionAaron Patterson2012-10-251-4/+5
|
* Support for multiple etags in an If-None-Match headerTravis Warlick2012-09-151-0/+39
| | | | | | | | This is a rebased version of #2520. Conflicts: actionpack/test/dispatch/request_test.rb
* Remove ActionDispatch::Head middleware in favor of Rack::HeadSantiago Pastorino2012-07-231-8/+0
| | | | Closes #7110 there's more work to do on rack-cache issue 69
* Raise ActionController::BadRequest for malformed parameter hashes.Andrew White2012-05-201-1/+1
| | | | | | | | | | | | | | Currently Rack raises a TypeError when it encounters a malformed or ambiguous hash like `foo[]=bar&foo[4]=bar`. Rather than pass this through to the application this commit captures the exception and re-raises it using a new ActionController::BadRequest exception. The new ActionController::BadRequest exception returns a 400 error instead of the 500 error that would've been returned by the original TypeError. This allows exception notification libraries to ignore these errors if so desired. Closes #3051
* Valid ips v4 and v6. Right logic for working with X-FORWARDED-FOR header and ↵Alexey Gaziev2012-04-251-20/+114
| | | | tests.
* Add config.default_method_for_update to support PATCHDavid Lee2012-02-221-4/+11
| | | | | | | | | | | | | | | | PATCH is the correct HTML verb to map to the #update action. The semantics for PATCH allows for partial updates, whereas PUT requires a complete replacement. Changes: * adds config.default_method_for_update you can set to :patch * optionally use PATCH instead of PUT in resource routes and forms * adds the #patch verb to routes to detect PATCH requests * adds #patch? to Request * changes documentation and comments to indicate support for PATCH This change maintains complete backwards compatibility by keeping :put as the default for config.default_method_for_update.
* Fix failing request testCarlos Antonio da Silva2012-02-071-1/+1
| | | | | | | | Latest changes in remote ip handling conflicted with each other in tests. Related: dd09811fa6214a130fdc2de1d4c00b4337cb15f9 6a720226aad2adffcbd2422d40db772719579e2f
* Merge pull request #2490 from gsterndale/x_forwarded_for_orderJosé Valim2012-02-071-4/+4
|\ | | | | The first IP address in the X-Forwarded-For header is the originating IP
| * The first IP address in the X-Forwarded-For header is the originating IPGreg Sterndale2012-02-071-4/+4
| |
* | Trusted proxies is replaced with a Regexp or appended to with a StringGreg Sterndale2012-02-071-2/+13
|/
* Add original_fullpath and original_url methods to RequestPiotr Sarnacki2011-12-211-0/+24
|
* add test for bug fixed in 4f2bf64Andre Arko2011-11-141-0/+5
|
* change tests to expect X-F-F over REMOTE_ADDRAndre Arko2011-11-131-2/+2
|
* :subdomain can now be specified with a value of false in url_for, allowing ↵Kamil Sobieraj2011-10-041-0/+1
| | | | for subdomain(s) removal from the host during link generation. Closes #2025