From 3969a4bebf7737aec0484cbf4ac4d2ca3511b6b7 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Sun, 9 Aug 2015 00:25:50 +0900 Subject: implement "http" URIs support (currently only 'with prior knowledge') --- lib/plum/http_connection.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/plum/http_connection.rb (limited to 'lib/plum/http_connection.rb') 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 -- cgit v1.2.3