aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-11-03 22:26:33 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-11-03 22:26:33 +0900
commitdc870b7b2e8da6f96c3e5141d0341d5a29ca38f4 (patch)
treef9d2516c38ac791353c4502443d786c4f94e5ab6 /lib
parente910b2e92536ead6adebb4f338abfa3da058550b (diff)
downloadplum-dc870b7b2e8da6f96c3e5141d0341d5a29ca38f4.tar.gz
http{s,}_server_connection: remove #run
Diffstat (limited to 'lib')
-rw-r--r--lib/plum/rack/server.rb1
-rw-r--r--lib/plum/rack/session.rb7
-rw-r--r--lib/plum/server/http_connection.rb7
-rw-r--r--lib/plum/server/https_connection.rb7
4 files changed, 6 insertions, 16 deletions
diff --git a/lib/plum/rack/server.rb b/lib/plum/rack/server.rb
index 5e34cd3..37ae166 100644
--- a/lib/plum/rack/server.rb
+++ b/lib/plum/rack/server.rb
@@ -52,6 +52,7 @@ module Plum
con = Session.new(app: @app,
plum: plum,
+ sock: sock,
logger: @logger,
server_push: @config[:server_push],
remote_addr: sock.peeraddr.last)
diff --git a/lib/plum/rack/session.rb b/lib/plum/rack/session.rb
index 8266b96..d0aedc5 100644
--- a/lib/plum/rack/session.rb
+++ b/lib/plum/rack/session.rb
@@ -8,9 +8,10 @@ module Plum
class Session
attr_reader :app, :plum
- def initialize(app:, plum:, logger:, server_push: true, remote_addr: "127.0.0.1")
+ def initialize(app:, plum:, sock:, logger:, server_push: true, remote_addr: "127.0.0.1")
@app = app
@plum = plum
+ @sock = sock
@logger = logger
@server_push = server_push
@remote_addr = remote_addr
@@ -24,7 +25,9 @@ module Plum
def run
begin
- @plum.run
+ while !@sock.closed? && !@sock.eof?
+ @plum << @sock.readpartial(1024)
+ end
rescue Errno::EPIPE, Errno::ECONNRESET => e
rescue StandardError => e
@logger.error("#{e.class}: #{e.message}\n#{e.backtrace.map { |b| "\t#{b}" }.join("\n")}")
diff --git a/lib/plum/server/http_connection.rb b/lib/plum/server/http_connection.rb
index f864691..0e9462c 100644
--- a/lib/plum/server/http_connection.rb
+++ b/lib/plum/server/http_connection.rb
@@ -14,13 +14,6 @@ module Plum
super(@sock.method(:write), local_settings)
end
- # Starts communication with the peer. It blocks until the io is closed, or reaches EOF.
- def run
- while !@sock.closed? && !@sock.eof?
- self << @sock.readpartial(1024)
- end
- end
-
# Closes the socket.
def close
super
diff --git a/lib/plum/server/https_connection.rb b/lib/plum/server/https_connection.rb
index 1903bc1..09e360f 100644
--- a/lib/plum/server/https_connection.rb
+++ b/lib/plum/server/https_connection.rb
@@ -6,10 +6,7 @@ module Plum
def initialize(sock, local_settings = {})
@sock = sock
super(@sock.method(:write), local_settings)
- end
- # Starts communication with the peer. It blocks until the io is closed, or reaches EOF.
- def run
if @sock.respond_to?(:cipher) # OpenSSL::SSL::SSLSocket-like
if CIPHER_BLACKLIST.include?(@sock.cipher.first) # [cipher-suite, ssl-version, keylen, alglen]
on(:negotiated) {
@@ -17,10 +14,6 @@ module Plum
}
end
end
-
- while !@sock.closed? && !@sock.eof?
- self << @sock.readpartial(1024)
- end
end
# Closes the socket.