Fixing NGINX Content-Length Header Bug Using Rack
I recently ran into an issue with early versions of NGINX not setting the Content-Length header for 201 responses. I fixed the bug using Rack.
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
I recently ran into an issue with early versions of NGINX not setting the Content-Length header for 201 responses. I fixed the bug using Rack.
Comments
I posted these comments on the authors’ blog, but I noticed not a single other post had comments to them so there’s a chance mine won’t appear either.
Either way; if your application conforms to the Rack specification (http://rack.rubyforge.org/doc/SPEC.html) it should not return a String as the response (1.9 compatibility). It, however, must respond to #each and it must yield a String on each iteration. This means #length on the response should return a bogus value and it cannot be used as the content length D:!
Also, there’s Rack::ContentLength that appears to be doing the same thing but in a slightly more proper way: http://rack.rubyforge.org/doc/Rack/ContentLength.html
Post a comment