yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH] use Unicorn::HttpParser#response_start_sent accessor
@ 2015-06-05  9:10 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-06-05  9:10 UTC (permalink / raw)
  To: yahns-public; +Cc: Eric Wong

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-05  9:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-05  9:10 [PATCH] use Unicorn::HttpParser#response_start_sent accessor Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).