aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #23611 from abhishekjain16/routes_optionsKasper Timm Hansen2016-02-121-2/+3
|\ | | | | Fix routes to match verb and URL path with -g option also.
| * Fixes routes to match verbs and path with -g optionAbhishek Jain2016-02-111-2/+3
| |
* | Add fixes accidentally removed.Kasper Timm Hansen2016-02-122-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Yesterday, when improving how `parsed_body` extracted a parser I wrote 77bbf1e. Then I thought that was too many changes in one commit and broke it up locally... or so I thought. When pushed the extra commits removed the changes! Wups! In shame, lob those changes together here: * 3b94c38 which meant to fix the CHANGELOG syntax error. * 5007df5 which meant to mention `parsed_body` in the docs. * 036a7a0 which meant to memoize the `parsed_body`.
* | Merge pull request #23612 from vipulnsward/23561-fix-routes-argsKasper Timm Hansen2016-02-121-2/+1
|\ \ | | | | | | Fix argument passing to rake routes
| * | - Fixed and removed long arguments to rake routesVipul A M2016-02-121-2/+1
| | | | | | | | | | | | | | | | | | - Fixed related documentation and usage all around Fixes #23561
* | | Memoize `parsed_body`.Kasper Timm Hansen2016-02-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | It's common to use several assertions on the parsed response. The response bodies aren't meant to be mutated. People should make new test requests instead. Thus, it should be safe to memoize the parsing.
* | | [ci skip] Mention `parsed_body` in docs.Kasper Timm Hansen2016-02-111-2/+1
| | | | | | | | | | | | Little easier to understand when you know the method that's used.
* | | Make `parsed_body` extract parser from the content type.Kasper Timm Hansen2016-02-112-5/+9
|/ / | | | | | | | | | | | | We're not guaranteed to have a `RequestEncoder` to assign on `get` requests because we aren't extracting the parser from the response content type. Until now.
* | Add `parsed_body` to spare writing out parsing routines.Kasper Timm Hansen2016-02-102-12/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When testing: ```ruby post articles_path, params: { article: { title: 'Ahoy!' } }, as: :json ``` It's common to want to make assertions on the response body. Perhaps the server responded with JSON, so you write `JSON.parse(response.body)`. But that gets tedious real quick. Instead add `parsed_body` which will automatically parse the reponse body as what the last request was encoded `as`.
* | Merge pull request #21671 from kaspth/integration-request-encoding-helpersDavid Heinemeier Hansson2016-02-101-4/+79
|\ \ | |/ |/| Add `as` to encode a request as a specific mime type.
| * Add `as` to encode a request as a specific mime type.Kasper Timm Hansen2016-01-041-4/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Turns ``` post articles_path(format: :json), params: { article: { name: 'Ahoy!' } }.to_json, headers: { 'Content-Type' => 'application/json' } ``` into ``` post articles_path, params: { article: { name: 'Ahoy!' } }, as: :json ```
* | `log_process_action` will return an array, so use `empty?`Aaron Patterson2016-02-091-1/+1
| | | | | | | | | | We don't need to use active support in this case because we know the type that will be returned.
* | Request#fullpath should not raise an exception, so remove the rescueAaron Patterson2016-02-091-1/+1
| |
* | AC::Request#format always returns a value, so we do not need to tryAaron Patterson2016-02-091-1/+1
| |
* | speed up string xor operation and reduce object allocationsAaron Patterson2016-02-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ``` [aaron@TC rails (master)]$ cat xor.rb a = "\x14b\"\xB4P8\x05\x8D\xC74\xC3\xEC}\xFDf\x8E!h\xCF^\xBF\xA5%\xC6\xF0\xA9\xF9x\x04\xFA\xF1\x82" b = "O.\xF7\x01\xA9D\xA3\xE1D\x7FU\x85\xFC\x8Ak\e\x04\x8A\x97\x91\xD01\x02\xA4G\x1EIf:Y\x0F@" def xor_byte_strings(s1, s2) s1.bytes.zip(s2.bytes).map { |(c1,c2)| c1 ^ c2 }.pack('c*') end def xor_byte_strings2(s1, s2) s2_bytes = s2.bytes s1.bytes.map.with_index { |c1, i| c1 ^ s2_bytes[i] }.pack('c*') end require 'benchmark/ips' require 'allocation_tracer' Benchmark.ips do |x| x.report 'xor_byte_strings' do xor_byte_strings a, b end x.report 'xor_byte_strings2' do xor_byte_strings2 a, b end end ObjectSpace::AllocationTracer.setup(%i{type}) result = ObjectSpace::AllocationTracer.trace do xor_byte_strings a, b end p :xor_byte_strings => result ObjectSpace::AllocationTracer.clear result = ObjectSpace::AllocationTracer.trace do xor_byte_strings2 a, b end p :xor_byte_strings2 => result [aaron@TC rails (master)]$ ruby -I~/git/allocation_tracer/lib xor.rb Calculating ------------------------------------- xor_byte_strings 10.087k i/100ms xor_byte_strings2 11.339k i/100ms ------------------------------------------------- xor_byte_strings 108.386k (± 5.8%) i/s - 544.698k xor_byte_strings2 122.239k (± 3.0%) i/s - 612.306k {:xor_byte_strings=>{[:T_ARRAY]=>[38, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}} {:xor_byte_strings2=>{[:T_ARRAY]=>[3, 0, 0, 0, 0, 0], [:T_DATA]=>[1, 0, 0, 0, 0, 0], [:T_IMEMO]=>[2, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}} ```
* | Merge pull request #23534 from bronson/fix-redefined-warningArthur Nogueira Neves2016-02-081-0/+1
|\ \ | | | | | | fix 'method redefined' warnings
| * | fix 'method redefined' warningsScott Bronson2016-02-061-0/+1
| | |
* | | Merge pull request #23532 from matthewd/live-interlockMatthew Draper2016-02-081-23/+28
|\ \ \ | | | | | | | | Hand off the interlock to the new thread in AC::Live
| * | | Hand off the interlock to the new thread in AC::LiveMatthew Draper2016-02-071-23/+28
| |/ / | | | | | | | | | | | | | | | Most importantly, the original request thread must yield its share lock while waiting for the live thread to commit -- otherwise a request's base and live threads can deadlock against each other.
* / / Add SVG as a default mime typeDavid Heinemeier Hansson2016-02-071-0/+1
|/ /
* | Avoid coupling Action Pack to Railties.Kasper Timm Hansen2016-02-061-1/+1
| | | | | | | | | | | | | | | | Referencing Rails.env without checking if it's defined couples us to Railties. Fix by avoiding the line breaks if we don't have an env check to rely on.
* | add missing requireAaron Patterson2016-02-051-0/+1
| |
* | disable controller / view thread spawning in testsAaron Patterson2016-02-052-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests can (and do) access the database from the main thread. In this case they were starting a transaction, then making a request. The request would create a new thread, which would allocate a new database connection. Since the main thread started a transaction that contains data that the new thread wants to see, the new thread would not see it due to data visibility from transactions. Spawning the new thread in production is fine because middleware should not be doing database manipulation similar to the test harness. Before 603fe20c it was possible to set the database connection id based on a thread local, but 603fe20c changes the connection lookup code to never look at the "connection id" but only at the thread object itself. Without that indirection, we can't force threads to use the same connection pool as another thread. Fixes #23483
* | Put some space for non-assets requests in development modePrathamesh Sonpatki2016-02-031-0/+2
| | | | | | | | - Fixes #23428.
* | Sleep well, sweet princeSean Griffin2016-02-021-1/+1
| | | | | | | | | | Prototype, you have served us well. But you are no longer how we make an XMLHttpRequest. RIP
* | Merge pull request #23396 from pschambacher/pschambacher/fix_assert_generatesRafael França2016-02-021-0/+1
|\ \ | | | | | | Duplicate assert_generates options before modifying it
| * | Duplicate assert_generates options before modifying itPierre Schambacher2016-02-011-0/+1
| | |
* | | Preparing for Rails 5.0.0.beta2Sean Griffin2016-02-011-1/+1
| | |
* | | Converge on filter.Kasper Timm Hansen2016-02-011-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | Some places were saying filter, while others said filter_options, spare the ambiguity and use filter throughout. This inlines a needless local variable and clarifies a route filter consists of defaults and values to match against.
* | | Simplify filter normalization.Kasper Timm Hansen2016-02-011-5/+3
| | | | | | | | | | | | | | | | | | | | | Assume the filter is a string, if it wasn't a hash and isn't nil. Remove needless else and rely on Ruby's default nil return. Add spaces within hash braces.
* | | Merge pull request #23225 from vipulnsward/20420-rake-routes-optionsKasper Timm Hansen2016-02-012-16/+21
|\ \ \ | | | | | | | | Add options for rake routes task
| * | | Add options for rake routes taskVipul A M2016-02-022-16/+21
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | Add two options: `-c` and `-g`. `-g` option returns the urls name, verb and path fields that match the pattern. `-c` option returns the urls for specific controller. Fixes #18902, and Fixes #20420 [Anton Davydov & Vipul A M]
* / / Add documentation for #17573Jon Moss2016-02-011-0/+8
|/ / | | | | | | | | | | Fixes some parts of #23148. [ci skip]
* | Merge pull request #23343 from y-yagi/remove_unused_requireRafael França2016-01-301-1/+0
|\ \ | | | | | | remove unused require
| * | remove unused requireyuuji.yaginuma2016-01-301-1/+0
| | | | | | | | | | | | `with_indifferent_access` had been used in `assigns` method, but has been removed in ca83436.
* | | Handle response_body= when body is nileileencodes2016-01-301-0/+1
|/ / | | | | | | | | | | | | | | | | There are some cases when the `body` in `response_body=` can be set to nil. One of those cases is in `actionpack-action_caching` which I found while upgrading it for Rails 5. It's not possible to run `body.each` on a `nil` body so we have to return after we run `response.reset_body!`.
* | Add additional documentation on Headers#[] [ci skip]Tawan Sierek2016-01-291-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #16519 covers confusion potentially caused by how HTTP headers, that contain underscores in their names, are retrieved through `ActionDispatch::Http::Headers#[]`. This confusion has its origin in how a CGI maps HTTP header names to variable names. Even though underscores in header names are rarely encountered, they are valid according to RFC822 [1]. Nonetheless CGI like variable names, as requested by the Rack specfication, will only contain underscores and therefore the original header name cannot be recovered after the Rack server passed on the environemnt hash. Please, see also the disscussion on StackOverflow [2], which also links to an explaination in the nginx documentation [3]. [1] http://www.ietf.org/rfc/rfc822.txt [2] http://stackoverflow.com/questions/22856136/why-underscores-are-forbidden-in-http-header-names [3] https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#missing-disappearing-http-headers
* | speed up accept header parsing a bit.Aaron Patterson2016-01-281-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Accept header is taken from what Safari on El Capitan sends: ```ruby require 'benchmark/ips' require 'action_dispatch/http/mime_type' require 'active_support/all' accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' Benchmark.ips do |x| x.report "omg" do Mime::Type.parse(accept) end end ``` Before: ``` [aaron@TC actionpack (master)]$ be ruby ../x.rb Calculating ------------------------------------- omg 3.181k i/100ms ------------------------------------------------- omg 35.062k (±12.8%) i/s - 174.955k [aaron@TC actionpack (master)]$ be ruby ../x.rb Calculating ------------------------------------- omg 3.153k i/100ms ------------------------------------------------- omg 33.724k (±12.4%) i/s - 167.109k [aaron@TC actionpack (master)]$ be ruby ../x.rb Calculating ------------------------------------- omg 3.575k i/100ms ------------------------------------------------- omg 37.251k (±10.4%) i/s - 185.900k ``` After: ``` [aaron@TC actionpack (master)]$ be ruby ../x.rb Calculating ------------------------------------- omg 3.365k i/100ms ------------------------------------------------- omg 40.069k (±16.1%) i/s - 198.535k [aaron@TC actionpack (master)]$ be ruby ../x.rb Calculating ------------------------------------- omg 4.168k i/100ms ------------------------------------------------- omg 47.596k (± 7.7%) i/s - 237.576k [aaron@TC actionpack (master)]$ be ruby ../x.rb Calculating ------------------------------------- omg 4.282k i/100ms ------------------------------------------------- omg 43.626k (±17.7%) i/s - 209.818k ```
* | convert AcceptList to a regular classAaron Patterson2016-01-281-20/+19
| | | | | | | | | | | | | | we never use this custom array outside the mime type `parse` method. We can reduce the interaction to just a regular array, so we should use that instead (IOW, there was nothing special about AcceptList so we should remove it).
* | remove == from AcceptItemAaron Patterson2016-01-271-6/+7
| | | | | | | | | | | | | | | | Remove nonsense definition of == from `AcceptItem`. The definition only compared names and not `q` values or even object identity. The only use was in the `assort!` method that really just wanted the index of the item given the item's name. Instead we just change the caller to use `index` with the block form.
* | remove useless private methodsAaron Patterson2016-01-271-13/+9
| | | | | | | | | | This commit refactors the private methods that were just aliases to [] to just directly use [] and cache the return values on the stack.
* | change `@app_xml_idx` to an lvar and cache it on the stackAaron Patterson2016-01-271-16/+10
| | | | | | | | | | same strategy as `@text_xml_idx`: cache it on the stack to avoid ivar lookups and the `||=` call.
* | change `@text_xml_idx` to an lvar and cache it on the stackAaron Patterson2016-01-271-13/+11
| | | | | | | | | | this eliminates the ivar lookup and also eliminates the `||=` conditional that happens every time we called the `text_xml_idx` method.
* | Fix typo in strong params hash deprecation messageMarek2016-01-271-2/+2
| | | | | | and remove unecessary spaces in string interpolation.
* | fix permitted? conditional for `render` callsAaron Patterson2016-01-261-3/+6
| |
* | Fix undefined error for `ActionController::Parameters`Jon Moss2016-01-261-6/+3
| |
* | Merge branch '5-0-beta-sec'Aaron Patterson2016-01-254-5/+30
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 5-0-beta-sec: bumping version fix version update task to deal with .beta1.1 Eliminate instance level writers for class accessors allow :file to be outside rails root, but anything else must be inside the rails view directory Don't short-circuit reject_if proc stop caching mime types globally use secure string comparisons for basic auth username / password
| * | bumping versionAaron Patterson2016-01-251-1/+1
| | |
| * | allow :file to be outside rails root, but anything else must be inside the ↵Aaron Patterson2016-01-221-1/+7
| | | | | | | | | | | | | | | | | | rails view directory CVE-2016-0752
| * | stop caching mime types globallyAaron Patterson2016-01-221-2/+16
| | | | | | | | | | | | | | | | | | | | | Unknown mime types should not be cached globally. This global cache leads to a memory leak and a denial of service vulnerability. CVE-2016-0751