aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware
Commit message (Collapse)AuthorAgeFilesLines
* rm `deep_munge`. You will live on in our hearts (and git history)Aaron Patterson2015-07-211-1/+1
| | | | | Now that we have encoding strategies, we can just walk the params hash once to encode as HWIA, and remove nils.
* Freeze string literals when not mutated.schneems2015-07-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I wrote a utility that helps find areas where you could optimize your program using a frozen string instead of a string literal, it's called [let_it_go](https://github.com/schneems/let_it_go). After going through the output and adding `.freeze` I was able to eliminate the creation of 1,114 string objects on EVERY request to [codetriage](codetriage.com). How does this impact execution? To look at memory: ```ruby require 'get_process_mem' mem = GetProcessMem.new GC.start GC.disable 1_114.times { " " } before = mem.mb after = mem.mb GC.enable puts "Diff: #{after - before} mb" ``` Creating 1,114 string objects results in `Diff: 0.03125 mb` of RAM allocated on every request. Or 1mb every 32 requests. To look at raw speed: ```ruby require 'benchmark/ips' number_of_objects_reduced = 1_114 Benchmark.ips do |x| x.report("freeze") { number_of_objects_reduced.times { " ".freeze } } x.report("no-freeze") { number_of_objects_reduced.times { " " } } end ``` We get the results ``` Calculating ------------------------------------- freeze 1.428k i/100ms no-freeze 609.000 i/100ms ------------------------------------------------- freeze 14.363k (± 8.5%) i/s - 71.400k no-freeze 6.084k (± 8.1%) i/s - 30.450k ``` Now we can do some maths: ```ruby ips = 6_226k # iterations / 1 second call_time_before = 1.0 / ips # seconds per iteration ips = 15_254 # iterations / 1 second call_time_after = 1.0 / ips # seconds per iteration diff = call_time_before - call_time_after number_of_objects_reduced * diff * 100 # => 0.4530373333993266 miliseconds saved per request ``` So we're shaving off 1 second of execution time for every 220 requests. Is this going to be an insane speed boost to any Rails app: nope. Should we merge it: yep. p.s. If you know of a method call that doesn't modify a string input such as [String#gsub](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37) please [give me a pull request to the appropriate file](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37), or open an issue in LetItGo so we can track and freeze more strings. Keep those strings Frozen ![](https://www.dropbox.com/s/z4dj9fdsv213r4v/let-it-go.gif?dl=1)
* Merge pull request #17102 from matthewd/load-interlockAaron Patterson2015-07-101-0/+21
|\ | | | | Concurrent load interlock (rm Rack::Lock)
| * Fix the Interlock middlewareMatthew Draper2015-07-091-5/+14
| | | | | | | | | | We can't actually lean on Rack::Lock's implementation, so we'll just copy it instead. It's simple enough that that's not too troubling.
| * Soften the lock requirements when eager_load is disabledMatthew Draper2015-07-091-0/+12
| | | | | | | | | | We don't need to fully disable concurrent requests: just ensure that loads are performed in isolation.
* | start disconnecting the parameter parser from the instanceAaron Patterson2015-07-101-3/+3
| | | | | | | | | | pass in the instance variable to start decoupling the meat of the parser from the instance of the middleware
* | drop a conditional by always assigningAaron Patterson2015-07-101-6/+5
| | | | | | | | | | We will always make an assignment to the env hash and eliminate a conditional
* | drop runtime conditionals in parameter parsingAaron Patterson2015-07-091-13/+9
|/ | | | | If we only deal with proc objects, then we can eliminate type checking in the parameter parsing middleware
* Send cookies with requesteileencodes2015-07-071-0/+4
|
* Refactor cookie_jar to decouple it from request objecteileencodes2015-07-051-7/+3
| | | | | | This change decouples `cookie_jar` allocation from the request object. We need this for moving controller tests to integration tests so we can access the `cookie_jar` object separately.
* ActionDispatch::SSL should keep original header's behaviorFumiaki MATSUSHIMA2015-06-141-1/+1
| | | | | | `ActionDispatch::SSL` changes headers to `Hash`. So some headers will be broken if there are some middlewares on ActionDispatch::SSL and if it uses `Rack::Utils::HeaderHash`.
* Handle param-parsing errors from Rack in ExceptionWrapperGrey Baker2015-06-121-1/+3
|
* Change the `index` arg of `ActionDispatch::Static#new` to a kwargYuki Nishijima2015-06-111-4/+3
|
* pass check_ip and proxies to GetIp constructorAaron Patterson2015-06-031-4/+4
| | | | | The `GetIp` class doesn't need to keep a reference to the middleware, so there is no reason to pass the middleware instance to the `GetIp` class
* Fix regression in #20017: wrong number of arguments errorJon Atack2015-05-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and use coherent quoting/spacing. This should hopefully fix a regression that was introduced with #20017, causing deployment pushes to Heroku to be rejected with the following trace: ArgumentError: wrong number of arguments (2 for 3) remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tatic.rb:16:in `initialize' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/gem s/heroku-deflater-0.5.3/lib/heroku-deflater/serve_zipped_assets.rb:15:in `new' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/gem s/heroku-deflater-0.5.3/lib/heroku-deflater/serve_zipped_assets.rb:15:in `initialize' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tack.rb:43:in `new' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tack.rb:43:in `build' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tack.rb:118:in `block in build' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tack.rb:118:in `each' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tack.rb:118:in `inject' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/actionpack/lib/action_dispatch/middleware/s tack.rb:118:in `build' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/engine.rb:509:in `app' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/application/finisher.rb: 34:in `block in <module:Finisher>' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/initializable.rb:30:in `instance_exec' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/initializable.rb:30:in `run' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/initializable.rb:55:in `block in run_initializers' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/initializable.rb:54:in `run_initializers' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/vendor/bundle/ruby/2.2.0/bun dler/gems/rails-0ef7e73f0af7/railties/lib/rails/application.rb:352:in `initialize!' remote: /tmp/build_a3b8845b716508af12d99859d1a58c5c/config/environment.rb:5:in `<top (required)>'
* config.static_index configures directory index "index.html" filenameEliot Sykes2015-05-281-4/+5
| | | | | | Set `config.static_index` to serve a static directory index file not named `index`. For example, to serve `main.html` instead of `index.html` for directory requests, set `config.static_index` to `"main"`.
* add a branch to eliminate multiple nil checksAaron Patterson2015-05-231-3/+5
| | | | | if we add an else conditional to the `presence` check, we can eliminate the second `||` branch in the caller
* move request id manipulation to the request objectAaron Patterson2015-05-221-6/+5
| | | | this way we can keep the knowledge of `env` hash keys in one place.
* Tiny documentation edits [ci skip]Robin Dupret2015-05-041-1/+1
| | | | | | * Fix a few typos * Wrap lines to 80 chars * Use `+` instead of `<tt>`
* Use ruby 1.9 lambda syntax in documentations [ci skip]Mehmet Emin İNAÇ2015-05-031-2/+2
|
* Document :tld_length option for cookies.Ryan Wallace2015-04-291-0/+3
|
* No need to capitalize verbs. [CI SKIP]Guo Xiang Tan2015-04-261-2/+2
|
* Add nodoc to some private constants [ci skip]Rafael Mendonça França2015-04-231-3/+3
|
* Merge pull request #19823 from sbhatore/doc_fix_1Rafael Mendonça França2015-04-231-0/+8
|\ | | | | [ci skip] Description inside Signed and Encrypted CookieJars added
| * Squashed commit of the following:Siddharth Bhatore2015-04-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | commit a88875ac6abaa4d8116b42af8cd71189ce3d44d3 Author: Siddharth Bhatore <sbhatore95@gmail.com> Date: Thu Apr 23 12:26:08 2015 +0530 [ci skip] Update doc fix cookies commit f175eaa7a21db898fc6c66334f770831028f9d00 Author: Siddharth Bhatore <sbhatore95@gmail.com> Date: Mon Apr 20 12:58:04 2015 +0530 Description inside Signed and Encrypted CookieJars added
* | [ci skip] Add, clean up docs in ActionDispatch ActionDispatch middlewareNick Cox2015-04-221-6/+13
| |
* | [ci skip] UpgradeLegacySignedCookieJar Doc fixSiddharth Bhatore2015-04-221-2/+2
|/
* [Rails4 regression] prevent thin and puma cause error in Non ASCII URL on ↵Toshi MARUYAMA2015-04-091-1/+1
| | | | | | | | | | | | | | | | | | | Windows * https://github.com/rails/rails/issues/19187 * https://github.com/rails/rails/pull/19533 * https://github.com/macournoyer/thin/issues/268 These are serious Rails 4 regression for Redmine Bitnami Windows users. https://community.bitnami.com/t/problems-with-3-0-1-installation-see-report-inside/30195/ It is not caused on webrick users. Related: * https://github.com/rack/rack/issues/732#issuecomment-67677272 * https://github.com/phusion/passenger/issues/1328
* Fix ActionDispatch::PublicExceptions returning string rack statusRyan Tomayko2015-03-231-2/+2
| | | | | | | | The status returned in the rack [status, headers, body] array was a string, which can cause problems with middleware that assumes the status will be a Fixnum. This likely never surfaced because other middleware to_i the status returned from downstream apps before passing it on.
* Also skip Content-Encoding and Vary header if 304Kohei Suzuki2015-03-121-3/+4
|
* 304 response should not include Content-Type headerKohei Suzuki2015-03-101-1/+3
| | | | | Rack::Lint raises an error saying "Content-Type header found in 304 response, not allowed".
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-03-013-3/+20
|\
| * Explained how to set session expiry through session_store configIain Beeston2015-02-273-3/+20
| | | | | | | | | | | | Most session stores offer an :expire_after option, but it's largely undocumented. Cookie store also supports a number of options via rack (these used to be documented in rails 2.3)
* | Change filter on /rails/info/routes to use an actual path regexp from railsbrainopia2015-02-232-67/+63
| | | | | | | | | | | | | | | | Change filter on /rails/info/routes to use an actual path regexp from rails and not approximate javascript version. Oniguruma supports much more extensive list of features than javascript regexp engine. Fixes #18402.
* | Aliased the ActionDispatch::Request#uuid method with ↵David Ilizarov2015-02-201-1/+1
| | | | | | | | ActionDispatch::Request#request_id
* | Freeze strings to reduce allocations in integration testseileencodes2015-02-181-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Moves `X-Request-ID`, `action_dispatch.request_id` and `HTTP_X_REQUEST_ID` strings to constants and freezes them. We are freezing these strings to reduce the number of allocations in Rails integration tests. The tests are spending a lot of time in GC and this reduces the amount of time spent from 12% to 9% (in combination with Rack PR that also freezes some strings). Number of allocations before this change: 1030722 Number of allocations after this change: 967722
* | Reduce the number of times `#clean_path_info` is calledeileencodes2015-02-181-3/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | It's unnecessary to call `#clean_path_info`. It doesn't need to be called on the path with each extension. This reduces allocations to `Rack::Utils` in integration tests. Before `#clean_path_info` from `Rack::Utils` (line 622) was number 2 in top 5 allocations: ``` [["rack/lib/rack/utils.rb", 499, :T_STRING], [51034, 4539, 71559, 0, 12, 1791120]] [["rack/lib/rack/utils.rb", 662, :T_STRING], [33012, 0, 27930, 0, 1, 1226009]] [["rails/activesupport/lib/active_support/notifications/fanout.rb", 55, :T_DATA], [29998, 0, 25380, 0, 1, 3230600]] [["rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [29996, 0, 25378, 0, 2, 1113840]] [["rails/activesupport/lib/active_support/notifications/instrumenter.rb", 52, :T_HASH], [29994, 147, 27014, 0, 11, 4897784]] ``` After `#clean_path_info` from `Rack::Utils` (line 622) does not appear in the top 5 highest allocations: ``` [["rack/lib/rack/utils.rb", 499, :T_STRING], [47617, 2414, 68969, 0, 12, 1667360]] [["rack/lib/rack/body_proxy.rb", 34, :T_ARRAY], [28230, 0, 26060, 0, 1, 1046800]] [["rails/activesupport/lib/active_support/notifications/fanout.rb", 55, :T_DATA], [28208, 0, 26042, 0, 1, 3034096]] [["rails/activesupport/lib/active_support/subscriber.rb", 99, :T_STRING], [28204, 0, 26040, 0, 1, 1046080]] [["rails/activesupport/lib/active_support/callbacks.rb", 165, :T_DATA], [28200, 0, 26046, 0, 2, 3451800]] ```
* require rack/utils in exception_wrapperAndrew Lazarus2015-02-121-0/+1
|
* Merge pull request #18721 from sj26/pre-discard-flashAaron Patterson2015-02-011-17/+23
|\ | | | | Pre-discard flash messages
| * Migrate old flash behaviourSamuel Cochran2015-01-301-0/+6
| |
| * Discard from flash before persisting in sessionSamuel Cochran2015-01-291-17/+17
| |
* | Show proper traces on Windows for the error pagesGenadi Samokovarov2015-02-011-2/+8
|/ | | | | | | | | | | | | | | | | | | | | | This is an issue brought up by @daniel-rikowski in rails/web-console#91. Citing his PR proposal here: > Prior to this, backtrace lines were simply split by a single colon. > > Unfortunately that is also the drive letter delimiter in Windows paths > which resulted in a lot of empty source fragments of "C:0". ("C" from > the drive letter and 0 from "/path/to/rails/file.rb:16".to_i) > > Now the trace line is split by the first colon followed by some digits, > which works for both Windows and Unix path styles. Now, the PR was sent against web-console, because of the templates copy issue we used to had. Instead of bothering the contributor to reopen the issue against upstream Rails itself, I will make sure he gets the credit by putting his name in [rails-contributors/hard_coded_authors.rb][]. [rails-contributors/hard_coded_authors.rb]: (https://github.com/fxn/rails-contributors/blob/master/app/models/names_manager/hard_coded_authors.rb).
* Changing sets -> set Lindsey Bieda2015-01-061-1/+1
| | | Updating some minor grammar issue.
* - Removed unused parameter to cookie serialize method and fixed usage of the ↵Vipul A M2014-12-241-4/+4
| | | | same elsewhere
* We don't need to call to_sym. Just compare the stringRafael Mendonça França2014-12-041-1/+1
|
* Merge pull request #17792 from rockrep/masterRafael Mendonça França2014-12-041-1/+1
|\ | | | | | | allow 'all' for :domain option in addition to :all
| * allow 'all' for :domain option in addition to :allrockrep2014-11-261-1/+1
| |
| * Revert "Invert precedence of content in ActionDispatch::Static"Andrew White2012-12-071-11/+7
| | | | | | | | This reverts commit c59734f756b79c39486c45273d2cc5d42cd0c864.
| * Invert precedence of content in ActionDispatch::StaticAndrew White2012-12-061-7/+11
| | | | | | | | | | | | | | | | | | | | This commit inverts the precedence in ActionDispatch::Static so that dynamic content will be served before static content. This is so that precompiled assets do not inadvertently get included when running in development mode - it should have no effect in production where static files are usually handled by the web server. Closes #6421
* | Action View is needed for DebugExceptionsRafael Mendonça França2014-12-021-0/+2
| | | | | | | | We should remove this dependency later.