diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-09 00:25:50 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2015-08-09 00:25:50 +0900 |
commit | 3969a4bebf7737aec0484cbf4ac4d2ca3511b6b7 (patch) | |
tree | a2e99488844ccf108563a6e282284bc6ddbbb619 /lib/plum/http_connection.rb | |
parent | e2d18a67f6d9f8c78afe1eba769b9d474011bf6c (diff) | |
download | plum-3969a4bebf7737aec0484cbf4ac4d2ca3511b6b7.tar.gz |
implement "http" URIs support (currently only 'with prior knowledge')
Diffstat (limited to 'lib/plum/http_connection.rb')
-rw-r--r-- | lib/plum/http_connection.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/plum/http_connection.rb b/lib/plum/http_connection.rb new file mode 100644 index 0000000..bde8b7d --- /dev/null +++ b/lib/plum/http_connection.rb @@ -0,0 +1,33 @@ +module Plum + class HTTPConnection < Connection + def initialize(io, local_settings = {}) + super + end + + private + def negotiate! + if @buffer.bytesize >= 4 + if CLIENT_CONNECTION_PREFACE.start_with?(@buffer) + negotiate_with_knowledge + else + negotiate_with_upgrade + end + end + # next + end + + def negotiate_with_knowledge + if @buffer.bytesize >= 24 + if @buffer.byteshift(24) == CLIENT_CONNECTION_PREFACE + @state = :waiting_settings + settings(@local_settings) + end + end + # next + end + + def negotiate_with_upgrade + raise NotImplementedError, "Parsing HTTP/1.1 is hard..." + end + end +end |