Michael Fischer <[email protected]> wrote:
> On Tue, Mar 24, 2015 at 11:55 PM, Eric Wong <[email protected]> wrote:
>
> > Actually, are you getting 502 errors returned from nginx in this case?
> > That would not be harmless. I suggest ensuring rack.input is
> > fully-drained if that is the case (perhaps using PrereadInput).
>
> No, they're all 200 responses with a zero-length body size. It's the
> first time I'd ever seen such a combination of symptoms.
OK, thanks for the update.
I was wondering if including a Unicorn::PostreadInput middleware should
be introduced to quiet your logs. It should have the same effect as
PrereadInput, but should provide better performance in the common case
and also be compatible with "rewindable_input false" users.
class Unicorn::PostreadInput
def initialize(app)
@app = app
end
def call(env)
input = env["rack.input"] # save it here, in case the app reassigns it
@app.call(env)
ensure
# Ensure the HTTP request is entirely read off the socket even
# if the app aborts early. This should prevent nginx from
# complaining about ECONNRESET errors.
unless env["rack.hijack_io"]
buf = ''
true while input.read(16384, buf)
buf.clear
end
end
end
(totally untested)
"Postread" doesn't sound quite right, though...