jruby/jruby-rack — Issue #84: JRuby-Rack suppresses error HTTP status codes from Rails
Author: janielongfellow
Created: 2012-01-12 21:01:06+00:00
State: open

I'm hesitant to file this as an issue, because it appears clear from the code that it's intended behavior, but I was trying to understand the reasoning behind the behavior.

I'm using jruby-rack (1.1.2) to host a Rails application on Tomcat. Everything works great, except when I want to return an HTTP error status code from Rails to my client. If I return an error code (like 401 - unauthorized), it gets turned into a status code of 200 by the time it gets to the client. I dug through the code and it's clear that this is intentional -- the ResponseCapture Java class has a bunch of conditionals to check for this case (isError / statusCode >= 400) and avoid returning the Ruby/Rails HTTP status codes and dump any body content if an error code occurs. My question is: why?

I hacked the java code to take out the error conditionals and confirmed that without them, the Rails error codes and body content get properly passed along to the client, but I wanted to make sure that there weren't other cases where error codes would come back through the servlet and cause problems or side effects I don't understand.

If you could lend me your insight about why jruby-rack discards these error cases, I'd appreciate it. JRuby-Rack works so seamlessly (and well!) that I'd really like to use it, but unfortunately the non-browser clients of my API need HTTP status codes.