yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH] use Unicorn::HttpParser#response_start_sent accessor
Date: Fri,  5 Jun 2015 09:10:50 +0000	[thread overview]
Message-ID: <1433495450-30724-1-git-send-email-e@80x24.org> (raw)

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


                 reply	other threads:[~2015-06-05  9:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1433495450-30724-1-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=yahns-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).