aboutsummaryrefslogtreecommitdiffstats
path: root/lib/plum
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-08-17 18:48:00 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-08-18 16:19:31 +0900
commitec059733e3e63ac461e8477638ad5d0a7d65dc58 (patch)
tree93832299c0009803075b757e6a4d1e2e1590cddb /lib/plum
parent850af19b0259fafaa196175c45f72de1ec7f5084 (diff)
downloadplum-ec059733e3e63ac461e8477638ad5d0a7d65dc58.tar.gz
http_connection: raise LegacyHTTPError instead of sending 505 (HTTP Version Not Supported) HTTP/1.1 response
Diffstat (limited to 'lib/plum')
-rw-r--r--lib/plum/errors.rb1
-rw-r--r--lib/plum/http_connection.rb17
2 files changed, 2 insertions, 16 deletions
diff --git a/lib/plum/errors.rb b/lib/plum/errors.rb
index 5b4b565..2770b27 100644
--- a/lib/plum/errors.rb
+++ b/lib/plum/errors.rb
@@ -1,5 +1,6 @@
module Plum
class Error < StandardError; end
+ class LegacyHTTPError < Error; end
class HPACKError < Error; end
class HTTPError < Error
ERROR_CODES = {
diff --git a/lib/plum/http_connection.rb b/lib/plum/http_connection.rb
index 4ffea73..b7ca046 100644
--- a/lib/plum/http_connection.rb
+++ b/lib/plum/http_connection.rb
@@ -35,8 +35,7 @@ module Plum
settings != nil)
switch_protocol(settings)
else
- respond_not_supported
- close
+ raise LegacyHTTPError.new
end
}
@@ -60,20 +59,6 @@ module Plum
io.write(resp)
end
- def respond_not_supported
- data = "Use modern web browser with HTTP/2 support."
-
- resp = ""
- resp << "HTTP/1.1 505 HTTP Version Not Supported\r\n"
- resp << "Content-Type: text/plain\r\n"
- resp << "Content-Length: #{data.bytesize}\r\n"
- resp << "Server: plum/#{Plum::VERSION}\r\n"
- resp << "\r\n"
- resp << data
-
- io.write(resp)
- end
-
def process_first_request
encoder = HPACK::Encoder.new(0, indexing: false) # don't pollute connection's HPACK context
stream = new_stream(1)