We don't need to waste a valuable ivar slot on each socket when we know unicorn already maintains this flag for us. --- lib/yahns/http_client.rb | 1 - lib/yahns/http_response.rb | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 620e925..7351171 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -20,7 +20,6 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: # called from acceptor thread def yahns_init @hs = Unicorn::HttpRequest.new - @response_start_sent = false @state = :headers # :body, :trailers, :pipelined, Wbuf, StreamFile @input = nil end diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 1ef2bbf..1be28bc 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -46,7 +46,7 @@ module Yahns::HttpResponse # :nodoc: end def response_start - @response_start_sent ? Z : RESPONSE_START + @hs.response_start_sent ? Z : RESPONSE_START end def response_wait_write(rv) @@ -94,7 +94,6 @@ module Yahns::HttpResponse # :nodoc: def http_response_done(alive) @input = @input.close if @input if alive - @response_start_sent = false # @hs.buf will have data if the client pipelined if @hs.buf.empty? @state = :headers @@ -224,7 +223,7 @@ module Yahns::HttpResponse # :nodoc: # returns nil on success # :wait_readable/:wait_writable/:close for epoll def do_ccc - @response_start_sent = true + @hs.response_start_sent = true wbuf = nil rv = nil CCC_RESPONSE_START.each do |buf| @@ -256,8 +255,8 @@ module Yahns::HttpResponse # :nodoc: # returns :close, :wait_writable, or :wait_readable def http_100_response(env) env.delete("HTTP_EXPECT") =~ /\A100-continue\z/i or return - buf = @response_start_sent ? "100 Continue\r\n\r\nHTTP/1.1 ".freeze - : "HTTP/1.1 100 Continue\r\n\r\n".freeze + buf = @hs.response_start_sent ? "100 Continue\r\n\r\nHTTP/1.1 ".freeze + : "HTTP/1.1 100 Continue\r\n\r\n".freeze case rv = kgio_trywrite(buf) when String -- EW