Skip to content

Instantly share code, notes, and snippets.

@acrosa
Created January 25, 2011 00:47
Show Gist options
  • Save acrosa/794309 to your computer and use it in GitHub Desktop.
Save acrosa/794309 to your computer and use it in GitHub Desktop.
required for doing early flush on JRuby under Tomcat
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