Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rails/rails
...
head fork: rails/rails
  • 9 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 19, 2012
@tenderlove tenderlove perform request inside a thread a6a5fda
@tenderlove tenderlove make sure the latch is released on exceptions 6471467
@tenderlove tenderlove stream is available on the response b403935
@tenderlove tenderlove removing the transver encoding header eb68521
@tenderlove tenderlove copy thread locals over to new thead 9fcdc4d
@tenderlove tenderlove move the latch to the response object 65253df
@tenderlove tenderlove fix variable names 7854451
Commits on Jul 24, 2012
@tenderlove tenderlove Merge branch 'master' into async
* master: (55 commits)
  fix typo in callbacks test
  Add CHANGELOG entry
  Remove ActionDispatch::Head middleware in favor of Rack::Head
  Fix build. Bump Journey requirements to 2.0.0.
  Bump Journey requirements to 1.0.4
  Add one more test case to make sure that data attributes are being escaped
  Restore connection_id on error.
  don't escape options in option_html_attributes method
  fixing :nodoc:s in AS::JSON::Encoding
  Remove deprecation warnings
  Add back `:disable_with` and change deprecation horizon to 4.1
  Add back `:confirm` and change deprecation horizon to 4.1
  +"foo"+ doesn't generate code tag [ci skip]
  Lets be consistent with whitespaces at documentation
  Copy-edits at Rails::Queueing documentation
  update 4.0 release notes [ci skip]
  improve NullRelation docs [ci skip]
  minor copy edits [ci skip]
  Revert "Make it clear that you can also pass a full url to assert_routing."
  makes a pass over the API of ActiveSupport::HashWithIndifferentAccess
  ...
648e198
Commits on Jul 27, 2012
@tenderlove tenderlove Merge branch 'master' into async
* master: (29 commits)
  Don't test language-level exception messages
  Modity the :json_data_empty attribute from `:null => false` to `:null => true` to address ORA-01400 errors with Oracle enhanced adapter.
  Add Object#try! with the old NoMethodError raising behavior
  will now return nil instead of raise a NoMethodError if the receiving object does not implement the method
  Changelog and doc updates for the previous changes.
  Deprecate Relation#all.
  Deprecate ActiveRecord::Base.scoped.
  ActiveRecord::Base.all returns a Relation.
  Only require the `:rails_env` task where is needed.
  Modify the preference attribute from `:null => false` to `:null => true` to address ORA-01400 errors with Oracle enhanced adapter.
  * Do not convert digest auth strings to symbols. CVE-2012-3424
  fix typo in documentation
  Refactor ActiveRecord::Inheritance.base_class logic
  Missed extend for eager_autoload
  Update activerecord/CHANGELOG.md
  Switched update_column recommendation in changelog to update_columns
  Eager autoload ActiveRecord association helpers
  Use string datatype for the setting attribute to make store works all database adapters.
  remove duplicate build runs in travis.  These extra runs were used to test identity map and not fully removed when the feature was removed.
  Deprecate update_column in favor of update_columns.
  ...
61e31f2
View
55 actionpack/lib/action_controller/metal/rack_delegation.rb
@@ -8,11 +8,64 @@ module RackDelegation
delegate :headers, :status=, :location=, :content_type=,
:status, :location, :content_type, :to => "@_response"
+ class AsyncResponse < ActionDispatch::Response
+ class Buffer
+ def initialize(response)
+ @response = response
+ @buf = Queue.new
+ end
+
+ def write(string)
+ @response.headers['Cache-Control'] = 'no-cache'
+ @response.headers.delete 'Content-Length'
+ @response.commit!
+ @buf.push string
+ end
+
+ def each
+ while str = @buf.pop
+ yield str
+ end
+ end
+
+ def close
+ @response.commit!
+ @buf.push nil
+ end
+ end
+
+ attr_reader :stream
+
+ def initialize(status = 200, header = {}, body = [])
+ @stream = Buffer.new self
+ super(status, header, stream)
+ end
+ end
+
def dispatch(action, request)
set_response!(request)
super(action, request)
end
+ def process(name)
+ t1 = Thread.current
+ locals = t1.keys.map { |key| [key, t1[key]] }
+
+ Thread.new {
+ t2 = Thread.current
+ t2.abort_on_exception = true
+ locals.each { |k,v| t2[k] = v }
+
+ begin
+ super(name)
+ ensure
+ @_response.commit!
+ end
+ }
+
+ @_response.await_commit
+ end
+
def response_body=(body)
response.body = body if response
super
@@ -25,7 +78,7 @@ def reset_session
private
def set_response!(request)
- @_response = ActionDispatch::Response.new
+ @_response = AsyncResponse.new
@_response.request = request
end
end
View
1  actionpack/lib/action_controller/test_case.rb
@@ -226,6 +226,7 @@ def recycle!
@block = nil
@length = 0
@body = []
+ @committed = false
@charset = @content_type = nil
@request = @template = nil
end
View
25 actionpack/lib/action_dispatch/http/response.rb
@@ -2,6 +2,7 @@
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/class/attribute_accessors'
+require 'monitor'
module ActionDispatch # :nodoc:
# Represents an HTTP response generated by a controller action. Use it to
@@ -62,12 +63,17 @@ class Response
include Rack::Response::Helpers
include ActionDispatch::Http::Cache::Response
+ include MonitorMixin
def initialize(status = 200, header = {}, body = [])
+ super()
+
self.body, self.header, self.status = body, header, status
@sending_file = false
- @blank = false
+ @blank = false
+ @cv = new_cond
+ @committed = false
if content_type = self[CONTENT_TYPE]
type, charset = content_type.split(/;\s*charset=/)
@@ -80,6 +86,23 @@ def initialize(status = 200, header = {}, body = [])
yield self if block_given?
end
+ def await_commit
+ synchronize do
+ @cv.wait_until { @committed }
+ end
+ end
+
+ def commit!
+ synchronize do
+ @committed = true
+ @cv.broadcast
+ end
+ end
+
+ def committed?
+ synchronize { @committed }
+ end
+
def status=(status)
@status = Rack::Utils.status_code(status)
end

No commit comments for this range

Something went wrong with that request. Please try again.