diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-11-16 18:48:35 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-11-16 18:48:35 +0900 |
commit | de62f5962e9047e867eb39ef933738ea3b9722c1 (patch) | |
tree | de71f3b397232151fb59929cd6f347c8d6598505 /lib | |
parent | cae4777e2da251aeb9a8377cb19f65fa2b2e757b (diff) | |
download | plum-de62f5962e9047e867eb39ef933738ea3b9722c1.tar.gz |
server/connection: reorganize subclasses
* HTTPSServerConnection is renamed to SSLSocketServerConnection
* HTTPServerConnection now accepts writer Proc (Method) instead of IO
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plum.rb | 2 | ||||
-rw-r--r-- | lib/plum/client.rb | 2 | ||||
-rw-r--r-- | lib/plum/rack/listener.rb | 6 | ||||
-rw-r--r-- | lib/plum/rack/session.rb | 3 | ||||
-rw-r--r-- | lib/plum/server/http_connection.rb | 15 | ||||
-rw-r--r-- | lib/plum/server/ssl_socket_connection.rb (renamed from lib/plum/server/https_connection.rb) | 2 |
6 files changed, 9 insertions, 21 deletions
diff --git a/lib/plum.rb b/lib/plum.rb index 95e5588..9452d8f 100644 --- a/lib/plum.rb +++ b/lib/plum.rb @@ -21,7 +21,7 @@ require "plum/connection" require "plum/stream_utils" require "plum/stream" require "plum/server/connection" -require "plum/server/https_connection" +require "plum/server/ssl_socket_connection" require "plum/server/http_connection" require "plum/client" require "plum/client/response" diff --git a/lib/plum/client.rb b/lib/plum/client.rb index 8cb9230..103d938 100644 --- a/lib/plum/client.rb +++ b/lib/plum/client.rb @@ -175,7 +175,7 @@ module Plum cert_store.set_default_paths ctx.cert_store = cert_store if @config[:http2] - ctx.ciphers = "ALL:!" + HTTPSServerConnection::CIPHER_BLACKLIST.join(":!") + ctx.ciphers = "ALL:!" + SSLSocketServerConnection::CIPHER_BLACKLIST.join(":!") if ctx.respond_to?(:alpn_protocols) ctx.alpn_protocols = ["h2", "http/1.1"] end diff --git a/lib/plum/rack/listener.rb b/lib/plum/rack/listener.rb index 079c680..c650ff0 100644 --- a/lib/plum/rack/listener.rb +++ b/lib/plum/rack/listener.rb @@ -25,7 +25,7 @@ module Plum end def plum(sock) - ::Plum::HTTPServerConnection.new(sock) + ::Plum::HTTPServerConnection.new(sock.method(:write)) end end @@ -62,7 +62,7 @@ module Plum def plum(sock) raise ::Plum::LegacyHTTPError.new("client doesn't offered h2 with ALPN", nil) unless sock.alpn_protocol == "h2" - ::Plum::HTTPSServerConnection.new(sock) + ::Plum::ServerConnection.new(sock.method(:write)) end private @@ -122,7 +122,7 @@ module Plum end def plum(sock) - ::Plum::HTTPSServerConnection.new(sock) + ::Plum::ServerConnection.new(sock.method(:write)) end end end diff --git a/lib/plum/rack/session.rb b/lib/plum/rack/session.rb index f95a10f..84f4869 100644 --- a/lib/plum/rack/session.rb +++ b/lib/plum/rack/session.rb @@ -28,9 +28,6 @@ module Plum 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")}") ensure @request_thread.each { |stream, thread| thread.kill } stop diff --git a/lib/plum/server/http_connection.rb b/lib/plum/server/http_connection.rb index 1860126..642bcbc 100644 --- a/lib/plum/server/http_connection.rb +++ b/lib/plum/server/http_connection.rb @@ -3,20 +3,11 @@ using Plum::BinaryString module Plum class HTTPServerConnection < ServerConnection - attr_reader :sock - - def initialize(sock, local_settings = {}) + def initialize(writer, local_settings = {}) require "http/parser" - @sock = sock @negobuf = String.new @_http_parser = setup_parser - super(@sock.method(:write), local_settings) - end - - # Closes the socket. - def close - super - @sock.close + super(writer, local_settings) end private @@ -68,7 +59,7 @@ module Plum "Server: plum/#{Plum::VERSION}\r\n" + "\r\n" - @sock.write(resp) + @writer.call(resp) end def process_first_request(parser, headers, body) diff --git a/lib/plum/server/https_connection.rb b/lib/plum/server/ssl_socket_connection.rb index bac1b4b..47e823a 100644 --- a/lib/plum/server/https_connection.rb +++ b/lib/plum/server/ssl_socket_connection.rb @@ -1,6 +1,6 @@ # -*- frozen-string-literal: true -*- module Plum - class HTTPSServerConnection < ServerConnection + class SSLSocketServerConnection < ServerConnection attr_reader :sock def initialize(sock, local_settings = {}) |