aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http
Commit message (Collapse)AuthorAgeFilesLines
...
* | remove more direct access to `env`Aaron Patterson2015-08-242-3/+4
| |
* | fewer calls to `env`Aaron Patterson2015-08-241-2/+2
| | | | | | | | We don't want to directly access the env hash
* | stop using `@env` in the GET / POST methodsAaron Patterson2015-08-241-2/+7
| | | | | | | | | | I want to implement this with something besides `@env` in the future, so lets stop directly referencing it.
* | use a request object in the session middlewareAaron Patterson2015-08-221-2/+2
| | | | | | | | | | This commit allows us to use one request object rather than allocating multiple request objects to deal with the session.
* | move more `@env` access to method callsAaron Patterson2015-08-221-16/+16
| | | | | | | | | | We're going to implement storing env values differently in the future, so let's disconnect these methods from the instance variables
* | move ORIGINAL_SCRIPT_NAME to the metaprogrammed methodsAaron Patterson2015-08-221-4/+1
| |
* | metaprogram the HTTP_X_REQUEST_ID methodAaron Patterson2015-08-221-6/+1
| | | | | | | | we're already doing this with a bunch of other header data.
* | use `body_stream` instead of getting the env value ourselvesAaron Patterson2015-08-221-1/+1
| | | | | | | | we have a method that knows how to get rack.input, so lets use that.
* | convert `@env` use to get / set headerAaron Patterson2015-08-221-16/+16
| | | | | | | | | | | | We need to abstract the internals of the request object away from this instance variable so that the values for `@env` can be calculated in a different way.
* | use get / set header to avoid depending on the `env` ivarAaron Patterson2015-08-221-11/+14
| |
* | Refactor to remove controller class from route to requesteileencodes2015-08-221-0/+12
| | | | | | | | | | | | | | | | | | | | This refactoring moves the controller class name that was on the route set to the request. The purpose of this refactoring is for changes we need to move controller tests to integration tests, mainly being able to access the controller on the request instead of having to go through the router. [Eileen M. Uchitelle & Aaron Patterson]
* | set cached values in the env hashAaron Patterson2015-08-211-6/+9
| |
* | stop directly accessing `@env` in mime_negotiationAaron Patterson2015-08-211-8/+8
| | | | | | | | | | we want to go through methods to access `env` because in the future that ivar may not be available, or may be calculated lazily
* | use public API to fetch the parameter filterAaron Patterson2015-08-211-2/+2
| | | | | | | | | | now the parameter filter doesn't need to know about the env hash in these two methds.
* | use methods on the request object to implement `fetch`Aaron Patterson2015-08-211-2/+8
| | | | | | | | Now the Headers internals don't depend on the env hash.
* | dup the env hash on Header#envAaron Patterson2015-08-211-1/+1
| | | | | | | | | | This prevents external mutations from impacting the internals of the request or the Header object.
* | use accessors on the request object for manipulating envAaron Patterson2015-08-211-3/+3
| | | | | | | | | | this reduces the API footprint for the env hash so that we can be more flexible when changing API in the future
* | use `set_header` rather than []=Aaron Patterson2015-08-211-1/+1
| | | | | | | | This allows us to avoid calling `env_name` twice.
* | dup the request and mutate its headers object.Aaron Patterson2015-08-211-2/+2
| | | | | | | | duping the request will dup it's underlying env hash.
* | pass a request object to the headers objectAaron Patterson2015-08-212-10/+16
| |
* | Simplify codeMarcin Olichwirowicz2015-08-131-5/+4
| | | | | | | | | | Since we are always responding with an array and using `any?`, we don't need to check if an array is empty
* | Avoid unnecessary MatchData objectsMarcin Olichwirowicz2015-08-131-1/+1
| |
* | deprecate the env method on controller instancesAaron Patterson2015-08-071-1/+1
| | | | | | | | | | | | people should be accessing request information through the request object, not via the env hash. If they really really want at the env hash, then they can get it off the request.
* | stop using @_env in the controller instanceAaron Patterson2015-08-071-0/+8
| | | | | | | | | | | | | | Actions are processed through `dispatch`, so they should have the request set on them before any user land code can be executed. Lets stop setting _env on the controller, and give access to it through the `env` method.
* | refactor param parsing middleware to use request objectsAaron Patterson2015-08-071-0/+8
| | | | | | | | | | this is another place that we should stop directly accessing the env hash and let the request object take care of that for us
* | Fix documentation on ActionDispatch::RequestGabriel Sobrinho2015-08-061-1/+1
| |
* | use a request object to access info from env in GetIpAaron Patterson2015-08-061-1/+7
| | | | | | | | | | | | | | again, we want to hide the contents of `env` from the implementation. Allocate a request object to access the contents of env, but save allocations due to string literal allocations when accessing the env hash.
* | ask the request if we should show exceptionsAaron Patterson2015-08-061-0/+7
| | | | | | | | | | hide the env key in the request object so that other code doesn't need to know.
* | prevent string allocationsAaron Patterson2015-08-061-1/+1
| |
* | get the underlying REQUEST_METHOD from the superclassAaron Patterson2015-08-061-1/+1
| |
* | Merge pull request #21131 from eagletmt/percent-filenameRafael Mendonça França2015-08-061-1/+7
|\ \ | | | | | | Fix Encoding::UndefinedConversionError with multibyte UTF-8 filename containing "%" character
| * | Assume uploaded filename is UTF-8Kohei Suzuki2015-08-051-1/+7
| | |
* | | routes in the env via the request objectAaron Patterson2015-08-051-0/+4
| | |
* | | allocate a request object to avoid hash allocationsAaron Patterson2015-08-051-0/+4
|/ / | | | | | | | | This decouples the `call` method from knowing the SCRIPT_NAME key and offloads decisions about how to access script_name
* | Tiny documentation edits [ci skip]Robin Dupret2015-07-281-1/+1
| |
* | Merge pull request #20590 from vngrs/set_default_charsetRafael Mendonça França2015-07-271-6/+6
|\ \ | | | | | | Document, refactor and create test case for ActionDispatch::Response
| * | Document, refactor and create test case for ↵Mehmet Emin İNAÇ2015-06-171-6/+6
| | | | | | | | | | | | ActionDispatch::Response#charset= method
* | | rm `deep_munge`. You will live on in our hearts (and git history)Aaron Patterson2015-07-211-7/+2
| | | | | | | | | | | | | | | Now that we have encoding strategies, we can just walk the params hash once to encode as HWIA, and remove nils.
* | | push param encoding in to the utils moduleAaron Patterson2015-07-211-14/+1
| | | | | | | | | | | | we'll refactor deep munge mostly out of existence shortly
* | | recurse for arrays in `normalize_encode_params`Aaron Patterson2015-07-211-5/+3
| | | | | | | | | | | | | | | this just pushes the conditional in to the case / when so we can switch to method dispatch later
* | | Freeze string literals when not mutated.schneems2015-07-192-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | | Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | This will silence deprecation warnings. Most of the test can be changed from `render :text` to render `:plain` or `render :body` right away. However, there are some tests that needed to be fixed by hand as they actually assert the default Content-Type returned from `render :body`.
* | | move buffer caching on to the bufferAaron Patterson2015-07-131-3/+11
| | |
* | | added description instead of remove usage [ci skip]Julio Lopez2015-07-111-1/+1
| | |
* | | Allow filtering params based on parent keysGuillaume Malette2015-06-221-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the possibility to only filter parameters based on their full path instead of relying on the immediate key. config.filter_parameters += ['credit_card.code'] { 'credit_card' => { 'code' => '[FILTERED]' }, 'source' => { 'code' => '<%= puts 5 %>' } }
* | | Fix the comment about attr_reader of headers [ci skip]Mehmet Emin İNAÇ2015-06-161-1/+1
|/ /
* | remove `header=` on the response object.Aaron Patterson2015-06-152-13/+14
| | | | | | | | | | | | People should be free to mutate the header object, but not to set a new header object. That header object may be specific to the webserver, and we need to hide it's internals.
* | set the default charset in response initializeAaron Patterson2015-06-151-4/+12
| | | | | | | | | | this way we don't have to mutate the instance (as much) when writing a rack response
* | A few documentation tweaks [ci skip]Robin Dupret2015-06-071-2/+2
| | | | | | | | [Robin Dupret & Shunsuke Aida]
* | Remove already defined methods in super class of ActionDispatch::Request classMehmet Emin İNAÇ2015-05-281-36/+0
| | | | | | | | | | | | | | These methods had defined in 2004 by dhh in initial commit and `ActionDispatch::Request` class has been inherited from `Rack::Request` class in 2009 by josh. In 2014 these methods and more of them defined in `Rack::Request` class so we don't need them anymore in rails codebase.