diff options
Diffstat (limited to 'lib/yahns/http_response.rb')
-rw-r--r-- | lib/yahns/http_response.rb | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index a520216..8a2426b 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -50,24 +50,20 @@ module Yahns::HttpResponse # :nodoc: wbuf = Yahns::Wbuf.new(body, alive, self.class.output_buffer_tmpdir) rv = wbuf.wbuf_write(self, header) body.each { |chunk| rv = wbuf.wbuf_write(self, chunk) } if body - wbuf_maybe(wbuf, rv, alive) + wbuf_maybe(wbuf, rv) end - def wbuf_maybe(wbuf, rv, alive) + def wbuf_maybe(wbuf, rv) 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) + case rv = wbuf.wbuf_close(self) + when :ignore # hijacked + @state = rv + when Yahns::StreamFile + @state = rv + :wait_writable + when true, false + http_response_done(rv) end else @state = wbuf @@ -188,7 +184,7 @@ module Yahns::HttpResponse # :nodoc: # (or :wait_readable for SSL) and hit Yahns::HttpClient#step_write if wbuf body = nil # ensure we do not close the body in ensure - wbuf_maybe(wbuf, rv, alive) + wbuf_maybe(wbuf, rv) else http_response_done(alive) end |