aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #19135 from yuki24/access-control-supportJeremy Daer2015-10-131-8/+14
|\ | | | | | | Add basic support for access control headers to ActionDispatch::Static
| * Add the ability of returning arbitrary headers to ActionDispatch::StaticYuki Nishijima2015-06-131-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now ActionDispatch::Static can accept HTTP headers so that developers will have control of returning arbitrary headers like 'Access-Control-Allow-Origin' when a response is delivered. They can be configured through `#config.public_file_server.headers`: config.public_file_server.headers = { "Cache-Control" => "public, max-age=60", "Access-Control-Allow-Origin" => "http://rubyonrails.org" } Also deprecate `config.static_cache_control` in favor of `config.public_file_server.headers`.
* | Merge pull request #21849 from yui-knk/refactor_regexp_to_stringAndrew White2015-10-122-5/+1
|\ \ | | | | | | Change `Journey::Route#verb` to return string instead of regexp.
| * | Change `Journey::Route#verb` to return string instead of regexp.yui-knk2015-10-032-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | By [this commit](https://github.com/rails/rails/commit/0b476de445faf330c58255e2ec3eea0f3a7c1bfc) `Journey::Route#verb` need not to return verb as regexp. The returned value is used by inspector, so change it to be a string. Add inspect_with_multiple_verbs test case to keep the behavior of inspector correctly.
* | | Allow multiple `root` routes in same scope levelRafael Sales2015-10-101-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an application has multiple root entries with different constraints, the current solution is to use `get '/'`. Example: **Currently I have to do:** ```ruby get '/', to: 'portfolio#show', constraints: ->(req) { Hostname.portfolio_site?(req.host) } get '/', to: 'blog#show', constraints: ->(req) { Hostname.blog_site?(req.host) } root 'landing#show' ``` **But I would like to do:** ```ruby root 'portfolio#show', constraints: ->(req) { Hostname.portfolio_site?(req.host) } root 'blog#show', constraints: ->(req) { Hostname.blog_site?(req.host) } root 'landing#show' ``` Other URL matchers such as `get`, `post`, etc, already allows this, so I think it's fair that `root` also allow it since it's just a shortcut for a `get` internally.
* | | used predicate methods to avoid is_a? checksRonak Jangir2015-10-102-3/+5
| | |
* | | Fix mounted engine named routes regressionMatthew Erhard2015-10-072-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating the url for a mounted engine through its proxy, the path should be the sum of three parts: 1. Any `SCRIPT_NAME` request header or the value of `ActionDispatch::Routing::RouteSet#relative_url_root`. 2. A prefix (the engine's mounted path). 3. The path of the named route inside the engine. Since commit https://github.com/rails/rails/commit/44ff0313c121f528a68b3bd21d6c7a96f313e3d3, this has been broken. Step 2 has been changed to: 2. A prefix (the value of `ActionDispatch::Routing::RouteSet#relative_url_root` + the engine's mounted path). The value of `ActionDispatch::Routing::RouteSet#relative_url_root` is taken into account in step 1 of the route generation and should be ignored when generating the mounted engine's prefix in step 2. This commit fixes the regression by having `ActionDispatch::Routing::RouteSet#url_for` check `options[:relative_url_root]` before falling back to `ActionDispatch::Routing::RouteSet#relative_url_root`. The prefix generating code then sets `options[:relative_url_root]` to an empty string. This empty string is used instead of `ActionDispatch::Routing::RouteSet#relative_url_root` and avoids the duplicate `relative_url_root` value in the final result. This resolves #20920 and resolves #21459
* | | use methods for accessing the cache control headersAaron Patterson2015-10-062-6/+9
| | | | | | | | | | | | | | | Use the methods rack provides so we don't have to worry about the exact header key.
* | | etag header is in Rack, so use it's response methodsAaron Patterson2015-10-061-6/+2
| | | | | | | | | | | | | | | Rack implements the Etag header manipulation methods, so we can use those instead of ours.
* | | Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-0614-79/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge pull request #21887 from abhishekjain16/doc_fixKasper Timm Hansen2015-10-061-1/+1
|\ \ \ | | | | | | | | Fix usage of word alternatively in docs [ci skip]
| * | | Fix usage of word alternatively in docs [ci skip]Abhishek Jain2015-10-061-1/+1
| | | |
* | | | [ci skip] Change 'an URL' to 'a URL' as URL doesn't have a vowel soundtanmay30112015-10-062-2/+2
|/ / /
* | | move file sending to the response objectAaron Patterson2015-10-054-29/+47
| | | | | | | | | | | | | | | | | | | | | Just a slight refactor that delegates file sending to the response object. This gives us the advantage that if a webserver (in the future) provides a response object that knows how to do accelerated file serving, it can implement this method.
* | | Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-10-043-3/+5
|\ \ \
| * | | Revert "proper raise ArgumentError, divided large text new line"Rafael Mendonça França2015-09-282-4/+4
| | | | | | | | | | | | | | | | This reverts commit 4147ab730e807f622e5260a5f876749ff41fef26.
| * | | proper raise ArgumentError, divided large text new lineGaurav Sharma2015-09-292-4/+4
| | | |
| * | | Renamed ‘Return’ to ‘Returns’ [ci skip]Ronak Jangir2015-09-282-3/+3
| | | |
| * | | [ci skip] Fix document of `ActionController::RequestForgeryProtection`yui-knk2015-09-281-0/+2
| | | | | | | | | | | | | | | | | | | | * add `end` to end of class definition * add a blank line between explanation and example code
* | | | Introduce `Headers#add`. Move `Response#add_header` upstream.Jeremy Daer2015-10-033-23/+8
| |/ / |/| | | | | | | | | | | | | | | | | * Introduce `ActionDispatch::Http::Headers#add` to add a value to a multivalued header. * Move `Response#add_header` upstream: https://github.com/rack/rack/pull/957 * Match upstream `Response#have_header?` -> `#has_header?` name change.
* | | Response#add_header for adding to multi-valued headers like VaryJeremy Daer2015-10-011-0/+20
| | |
* | | Don't set a nil Set-Cookie header when there aren't any cookies. Omit the ↵Jeremy Daer2015-10-011-1/+3
| | | | | | | | | | | | header.
* | | remove useless methodAaron Patterson2015-09-281-4/+0
| | | | | | | | | | | | | | | the caller of `handle_conditional_get!` checks the committed state of the response, so we don't need to in the subclass.
* | | Merge pull request #21768 from Gaurav2728/gaurav-doc_fix_for_mimeRafael Mendonça França2015-09-251-1/+1
|\ \ \ | | | | | | | | fix Mime type in doc since mime types via constants is deprecated [ci…
| * | | fix Mime type in doc since mime types via constants is deprecated [ci skip]Gaurav Sharma2015-09-261-1/+1
| | | |
* | | | inherit from our AbstractStoreAaron Patterson2015-09-251-5/+1
| | | |
* | | | pull the flash methods in to their own moduleAaron Patterson2015-09-252-34/+41
| | | | | | | | | | | | | | | | | | | | | | | | We only want to activate flash when the user has enabled it. Api servers don't use flash, so add an empty implementation to the base Request object.
* | | | commit the flash after the controller finishes being servicedAaron Patterson2015-09-253-25/+17
| | | | | | | | | | | | | | | | | | | | Committing the flash needs to happen in order for the session to be written correctly, so lets guarantee that it actually does happen.
* | | | move flash committing to the request object.Aaron Patterson2015-09-252-12/+16
|/ / / | | | | | | | | | | | | I'm doing this so that we can commit the flash to the session object Out of Band of the flash middleware
* | | 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`
* | | build the Set-Cookie header functionallyAaron Patterson2015-09-241-5/+18
| | | | | | | | | | | | | | | Use the Rack utility methods for functional header manipulation. This helps to eliminate coupling on the header hash
* | | move the Header hash to the super classAaron Patterson2015-09-242-28/+24
| | | | | | | | | | | | | | | | | | | | | I want to move the header hash to the super request object in order to consolidate behavior. We should be switching out buffering strategies rather than header strategies since things like "mutating headers after send" is an error in both cases (buffering vs streaming).
* | | mutate headers before committing the responseAaron Patterson2015-09-241-2/+8
| | | | | | | | | | | | We should not mutate headers after the response has been committed.
* | | stop directly setting headers on the controllerAaron Patterson2015-09-231-5/+0
| | | | | | | | | | | | | | | again, since we are going through the test harness, all this is done for us.
* | | stop constructing a request object in this setterAaron Patterson2015-09-231-1/+0
| | | | | | | | | | | | | | | Since we just go through the normal test harness that sets up a request for us, we don't need to do this anymore.
* | | stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-235-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm making this change so that I can construct response objects that *don't* have the default headers applied. For example, I would like to construct a response object from the return value of a controller. If you need to construct a response object with the default headers, then please use the alternate constructor: `ActionDispatch::Response.create`
* | | Document Bearer prefix for Authorization header [ci skip]Eliot Sykes2015-09-231-5/+7
| | |
* | | Updated Mime Negotiations docs [ci skip]amitkumarsuroliya2015-09-232-6/+6
| | | | | | | | | As we all know that Accessing mime types via constants is deprecated. Now, we are using `Mime::Type[:JSON]` instead of `Mime::JSON`
* | | ask the request object for the sessionAaron Patterson2015-09-221-1/+1
| | | | | | | | | | | | | | | The flash middleware shouldn't know how to look up the session object. Just ask the request for that information.
* | | don't deal with `nil` valuesAaron Patterson2015-09-222-1/+7
| | | | | | | | | | | | | | | We can know whether or not there is a content type object, and just exit early. There is no need to `try` so hard.
* | | 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-212-1/+7
| | | | | | | | | | | | | | | 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.
* | | swap upcase and to_symAaron Patterson2015-09-211-1/+1
| | |
* | | stop calling deprecated methodsAaron Patterson2015-09-2111-27/+27
| | | | | | | | | | | | | | | 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-213-7/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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`.