Created
January 25, 2011 00:47
-
-
Save acrosa/794309 to your computer and use it in GitHub Desktop.
required for doing early flush on JRuby under Tomcat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JRuby::Rack::Response | |
def write_body(response) | |
stream = response.getOutputStream | |
begin | |
@body.each do |el| | |
stream.write(el.to_java_bytes) | |
stream.flush | |
end | |
rescue LocalJumpError => e | |
# HACK: deal with objects that don't comply with Rack specification | |
@body = [@body.to_s] | |
retry | |
ensure | |
@body.close if @body.respond_to?(:close) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment