diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-11-06 07:37:36 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-11-06 07:38:00 +0000 |
commit | 52f2a4055a0f7e27df02d40bb42dda446dcdf89d (patch) | |
tree | f70ef7c9b99a902de285c3b54e022e845cda826f | |
parent | 4263f312f25a8ccb197617ba46914d9734a24431 (diff) | |
download | yahns-52f2a4055a0f7e27df02d40bb42dda446dcdf89d.tar.gz |
We may buffer a response partially, but no longer need the buffer if we entered bypass mode. When doing this, we must remember to close the body after using it.
-rw-r--r-- | lib/yahns/http_response.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 8a4bd6a..a520216 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -54,16 +54,20 @@ module Yahns::HttpResponse # :nodoc: end def wbuf_maybe(wbuf, rv, alive) - case rv # trysendfile return value - when nil - case alive - when :ignore - @state = alive - when Yahns::StreamFile - @state = alive - :wait_writable - when true, false - http_response_done(alive) + case rv # wbuf_write return value + when nil # all done + begin + case alive + when :ignore # hijacked + @state = alive + when Yahns::StreamFile + @state = alive + :wait_writable + when true, false + http_response_done(alive) + end + ensure + wbuf.wbuf_close(self) end else @state = wbuf |