aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-11-03 11:53:57 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-11-03 12:04:22 +0900
commit3bec944cea2d7c5f09198747e9e33c4cfdbb5cd4 (patch)
tree6ac5516b441e25e4b96dd707171ae2467235bd49 /lib/plum
parent3a52f04bc7842dd11df6710d10522ad06180d3b2 (diff)
downloadplum-3bec944cea2d7c5f09198747e9e33c4cfdbb5cd4.tar.gz
split server into plum/server
Diffstat (limited to 'lib/plum')
-rw-r--r--lib/plum/connection.rb13
-rw-r--r--lib/plum/rack/listener.rb6
-rw-r--r--lib/plum/server/connection.rb18
-rw-r--r--lib/plum/server/http_connection.rb (renamed from lib/plum/http_connection.rb)2
-rw-r--r--lib/plum/server/https_connection.rb (renamed from lib/plum/https_connection.rb)2
5 files changed, 23 insertions, 18 deletions
diff --git a/lib/plum/connection.rb b/lib/plum/connection.rb
index a8b2916..df3d7b3 100644
--- a/lib/plum/connection.rb
+++ b/lib/plum/connection.rb
@@ -36,7 +36,6 @@ module Plum
@max_odd_stream_id = 0
@max_even_stream_id = 0
end
- private :initialize
# Emits :close event. Doesn't actually close socket.
def close
@@ -79,18 +78,6 @@ module Plum
@writer.call(frame.assemble)
end
- def negotiate!
- unless CLIENT_CONNECTION_PREFACE.start_with?(@buffer.byteslice(0, 24))
- raise ConnectionError.new(:protocol_error) # (MAY) send GOAWAY. sending.
- end
-
- if @buffer.bytesize >= 24
- @buffer.byteshift(24)
- @state = :waiting_settings
- settings(@local_settings)
- end
- end
-
def new_stream(stream_id, **args)
if stream_id.even?
@max_even_stream_id = stream_id
diff --git a/lib/plum/rack/listener.rb b/lib/plum/rack/listener.rb
index 31bbc8c..b479691 100644
--- a/lib/plum/rack/listener.rb
+++ b/lib/plum/rack/listener.rb
@@ -25,7 +25,7 @@ module Plum
end
def plum(sock)
- ::Plum::HTTPConnection.new(sock)
+ ::Plum::HTTPServerConnection.new(sock)
end
end
@@ -56,7 +56,7 @@ module Plum
end
def plum(sock)
- ::Plum::HTTPSConnection.new(sock)
+ ::Plum::HTTPSServerConnection.new(sock)
end
private
@@ -116,7 +116,7 @@ module Plum
end
def plum(sock)
- ::Plum::HTTPSConnection.new(sock)
+ ::Plum::HTTPSServerConnection.new(sock)
end
end
end
diff --git a/lib/plum/server/connection.rb b/lib/plum/server/connection.rb
new file mode 100644
index 0000000..a801d92
--- /dev/null
+++ b/lib/plum/server/connection.rb
@@ -0,0 +1,18 @@
+# -*- frozen-string-literal: true -*-
+using Plum::BinaryString
+module Plum
+ class ServerConnection < Connection
+ private
+ def negotiate!
+ unless CLIENT_CONNECTION_PREFACE.start_with?(@buffer.byteslice(0, 24))
+ raise ConnectionError.new(:protocol_error) # (MAY) send GOAWAY. sending.
+ end
+
+ if @buffer.bytesize >= 24
+ @buffer.byteshift(24)
+ settings(@local_settings)
+ @state = :waiting_settings
+ end
+ end
+ end
+end
diff --git a/lib/plum/http_connection.rb b/lib/plum/server/http_connection.rb
index 1c30e6e..f864691 100644
--- a/lib/plum/http_connection.rb
+++ b/lib/plum/server/http_connection.rb
@@ -2,7 +2,7 @@
using Plum::BinaryString
module Plum
- class HTTPConnection < Connection
+ class HTTPServerConnection < ServerConnection
attr_reader :sock
def initialize(sock, local_settings = {})
diff --git a/lib/plum/https_connection.rb b/lib/plum/server/https_connection.rb
index c719c2e..1903bc1 100644
--- a/lib/plum/https_connection.rb
+++ b/lib/plum/server/https_connection.rb
@@ -1,6 +1,6 @@
# -*- frozen-string-literal: true -*-
module Plum
- class HTTPSConnection < Connection
+ class HTTPSServerConnection < ServerConnection
attr_reader :sock
def initialize(sock, local_settings = {})