aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/live.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-1/+3
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* [docs] fix ActionController documentationHrvoje Šimić2017-03-121-4/+4
| | | | [ci skip]
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* Fix deadlock that can occur when child live thread tries to load a constant ↵Alex Chinn2016-08-151-1/+6
| | | | after writing to the stream.
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-11/+11
|
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-3/+3
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Merge pull request #24029 from ↵Sean Griffin2016-05-061-8/+8
|\ | | | | | | | | | | | | rthbound/dont-call-each-when-calling-body-on-response Dont call each when calling body on response to fix #23964 Fixes #23964
| * Fixes #23964Ryan T. Hosford2016-03-131-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Adds #each_chunk to ActionDispatch::Response. it's a method which will be called by ActionDispatch::Response#each. - Make Response#each a proper method instead of delegating to @stream - In Live, instead of overriding #each, override #each_chunk. - `#each` should just spit out @str_body if it's already set - Adds #test_set_header_after_read_body_during_action to prove this fixes #23964 - Adds #test_each_isnt_called_if_str_body_is_written to ensure #each_chunk is not called when @str_body is available - Call `@response.sent!` in AC::TestCase's #perform so a test response acts a bit more like a real response. Makes test that call `#assert_stream_closed` pass again. - Additionally assert `#committed?` in `#assert_stream_closed` - Make test that was calling @response.stream.each pass again by calling @response.each instead.
* | Actionpack documentation typos [ci skip]Tom Kadwill2016-04-231-2/+2
|/
* 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.
* disable controller / view thread spawning in testsAaron Patterson2016-02-051-2/+13
| | | | | | | | | | | | | | | | | | 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
* Fix `make_response!` when called by `serve` in `RouteSet`eileencodes2015-12-091-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | All of our tests were testing the `ActionController::Live` behavior in a standalone environment, without going through the router or behaving like a real application. This resulted in `ActionController::Live` throwing the exception `undefined method 'request' for #<ActionDispatch::Request:0x00000003ad1148>` because `make_response!` was expecting a response instead of a request. The expectation of a response came from `set_response!` in non-router tests setting the response and passing it to `make_response!`. In the case of an application we would hit `serve` in `RouteSet` first which would send us to `make_response!` with a request sent instead of a response. The changes here remove `set_response!` so `make_response!` always receives a request. Thanks to KalabiYau for help with the investigation and solution. Fixes #22524 [Eileen M. Uchitelle & KalabiYau]
* Push `before_sending` to super classeileencodes2015-12-061-6/+0
| | | | | | | | | | | | We want to get rid of the `Live::Response` so we are consolidating methods from `Live::Response` and `Response` by merging them together. This adds an `#empty` method to the request so we don't need to hard-code the empty array each time we call an empty `ActionDispatch::Request`. The work here is a continuation on combining controller and integration test code bases into one.
* use `dispatch` instead of `process` to run requests thougheileencodes2015-10-291-4/+5
| | | | | | | | | `dispatch` sets the request and response on the controller for us automatically, so the test harness doesn't need to know the internals of how request / response is set. Conflicts: actionpack/lib/action_controller/test_case.rb
* 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.
* move the Header hash to the super classAaron Patterson2015-09-241-27/+0
| | | | | | | 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).
* stop applying default headers in ActionDispatch::ResponseAaron Patterson2015-09-231-4/+4
| | | | | | | | | | 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`
* use accessors instead of manipulating the hashAaron Patterson2015-09-081-2/+2
| | | | | in the future I would like to make the header hash read only (or at least remove guarantees that mutations will do anything).
* move response allocation to the class levelAaron Patterson2015-08-251-6/+15
| | | | | | we don't need an instance to figure out what type of response to allocate. Later we'll pull this up the stack and pass the response object down
* Freeze static arguments for gsubbrainopia2015-04-021-1/+1
|
* Prefer string patterns for gsubbrainopia2015-04-021-1/+1
| | | | | | | | | | | | | | | | | https://github.com/ruby/ruby/pull/579 - there is a new optimization since ruby 2.2 Previously regexp patterns were faster (since a string was converted to regexp underneath anyway). But now string patterns are faster and better reflect the purpose. Benchmark.ips do |bm| bm.report('regexp') { 'this is ::a random string'.gsub(/::/, '/') } bm.report('string') { 'this is ::a random string'.gsub('::', '/') } bm.compare! end # string: 753724.4 i/s # regexp: 501443.1 i/s - 1.50x slower
* remove unused #await_closeSergey Alekseev2014-12-041-6/+0
| | | | | | | | | The method was added in https://github.com/rails/rails/commit/30d21dfcb7fafe49b3805b8249454485a90097b6#diff-5055d9f16b442adb1d2f0f65903a196bR141. With the method call in https://github.com/rails/rails/commit/30d21dfcb7fafe49b3805b8249454485a90097b6#diff-cc7bb557df2247c0a42bc180fdb6eb05R47. Later one more method call was added in https://github.com/rails/rails/commit/401787db4bc428dce88b04e343a64c6a6c3b681c#diff-cc7bb557df2247c0a42bc180fdb6eb05R183. And both method calls were deleted in https://github.com/rails/rails/commit/3df07d093a1e4207caa63fd2e3b67599211f5800#diff-cc7bb557df2247c0a42bc180fdb6eb05L47 and https://github.com/rails/rails/commit/3df07d093a1e4207caa63fd2e3b67599211f5800#diff-cc7bb557df2247c0a42bc180fdb6eb05L189. Just do `grep -nr 'await_close' .`.
* Call gsub with a Regexp instead of a String for better performancePablo Herrero2014-11-011-1/+1
|
* Pass block for logging.Guo Xiang Tan2014-08-091-4/+6
| | | | This follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
* `:nodoc: all` does not remove the constants from the API. [ci skip]Yves Senn2014-06-241-1/+1
| | | | | Need to add individual `:nodoc:` for nested classes / modules to completely remove the constants from the API.
* Handle client disconnect during live streamingMatthew Draper2014-06-081-0/+48
| | | | .. even when the producer is blocked for a write.
* Add multiple lines message support for SSE moduleayaya2014-05-121-1/+2
|
* re-raise error if error occurs before committing in streamingKevin Casey2014-03-141-10/+11
| | | | update the tests, using an if-else
* use the body proxy to freeze headersAaron Patterson2014-03-121-2/+8
| | | | | | avoid freezing the headers until the web server has actually read data from the body proxy. Once the webserver has read data, then we should throw an error if someone tries to set a header
* just ask the response for the commit status, we do not need to ask the jarAaron Patterson2014-03-121-1/+1
|
* only write the jar if the response isn't committedAaron Patterson2014-03-121-4/+8
| | | | | | | | | | | when streaming responses, we need to make sure the cookie jar is written to the headers before returning up the stack. This commit introduces a new method on the response object that writes the cookie jar to the headers as the response is committed. The middleware and test framework will not write the cookie headers if the response has already been committed. fixes #14352
* use built-in exception handling in live controllersAaron Patterson2014-02-281-2/+5
| | | | | | when an exception happens in an action before the response has been committed, then we should re-raise the exception in the main thread. This lets us reuse the existing exception handling.
* live controllers should have live responsesAaron Patterson2014-02-281-2/+14
| | | | | | detect the type of controller we're testing and return the right type of response based on that controller. This allows us to stop doing the weird sleep thing.
* set the error callback to a nice default in case nobody set an error ↵Aaron Patterson2014-02-281-1/+1
| | | | callback and an error happens
* Correct prestreaming controller response status.Kevin Casey2014-02-151-0/+2
| | | | | | if the controller action has not yet streamed any data, actions should process as normal, and errors should trigger the appropriate behavior (500, or in the case of ActionController::BadRequest, a 400 Bad Request)
* Merge branch 'master' into laurocaetano-fix_send_fileAaron Patterson2014-01-101-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (536 commits) doc, API example on how to use `Model#exists?` with multiple IDs. [ci skip] Restore DATABASE_URL even if it's nil in connection_handler test [ci skip] - error_messages_for has been deprecated since 2.3.8 - lets reduce any confusion for users Ensure Active Record connection consistency Revert "ask the fixture set for the sql statements" Check `respond_to` before delegation due to: https://github.com/ruby/ruby/commit/d781caaf313b8649948c107bba277e5ad7307314 Adding Hash#compact and Hash#compact! methods MySQL version 4.1 was EOL on December 31, 2009 We should at least recommend modern versions of MySQL to users. clear cache on body close so that cache remains during rendering add a more restricted codepath for templates fixes #13390 refactor generator tests to use block form of Tempfile Fix typo [ci skip] Move finish_template as the last public method in the generator Minor typos fix [ci skip] make `change_column_null` reversible. Closes #13576. create/drop test and development databases only if RAILS_ENV is nil Revert "Speedup String#to" typo fix in test name. [ci skip]. `core_ext/string/access.rb` test what we are documenting. Fix typo in image_tag documentation ... Conflicts: actionpack/CHANGELOG.md
| * Spelling and Grammar checksAkshay Vishnoi2013-12-121-1/+1
| |
* | Fix stream closing when sending file with `ActionController::Live` included.Lauro Caetano2013-11-301-1/+1
|/ | | | Fixes #12381
* Creating an SSE class to be used with ActionController::Live.wangjohn2013-07-301-0/+74
|
* Fix typoRafael Mendonça França2013-04-091-2/+2
|
* fix AP warning; remove unused variableVipul A M2013-04-091-0/+1
|
* Exception handling for controllers using ActionController::LiveSean Griffin2013-03-181-0/+28
| | | | | | | | | Any exceptions that occured at the view or controller level for a controller using ActionController::Live would cause the server to either hang with an open socket indefinitely, or immediately crash (depending on whether the server was launched with rails s or directly). Changed the behavior of exceptions to act the same as streaming templates for html requests, and allow for an on_error callback if needed.
* Handle conditional get in live requests - this will prevent error when using ↵Bernard Potocki2013-03-141-0/+4
| | | | stale on live streams(issue #9636)
* ensure response.stream is closedSam Ruby2013-03-091-0/+1
|
* push header merge down to a private method so that live responses can have ↵Aaron Patterson2012-08-131-5/+4
| | | | their own header object
* live response headers can be merged with a hashAaron Patterson2012-08-131-0/+4
|
* use a sized buffer to prevent the queue being too largeAaron Patterson2012-08-081-10/+10
|