Class: Plum::HTTPConnection
- Inherits:
-
Connection
- Object
- Connection
- Plum::HTTPConnection
- Defined in:
- lib/plum/http_connection.rb
Constant Summary
Constants inherited from Connection
Connection::CLIENT_CONNECTION_PREFACE, Connection::DEFAULT_SETTINGS
Instance Attribute Summary collapse
-
#sock ⇒ Object
readonly
Returns the value of attribute sock.
Attributes inherited from Connection
#hpack_decoder, #hpack_encoder, #local_settings, #remote_settings, #state, #streams
Attributes included from FlowControl
#recv_remaining_window, #send_remaining_window
Instance Method Summary collapse
-
#close ⇒ Object
Closes the socket.
-
#initialize(sock, local_settings = {}) ⇒ HTTPConnection
constructor
A new instance of HTTPConnection.
-
#run ⇒ Object
Starts communication with the peer.
Methods inherited from Connection
Methods included from ConnectionUtils
#goaway, #ping, #push_enabled?, #settings
Methods included from FlowControl
Methods included from EventEmitter
Constructor Details
#initialize(sock, local_settings = {}) ⇒ HTTPConnection
Returns a new instance of HTTPConnection.
7 8 9 10 11 12 13 14 |
# File 'lib/plum/http_connection.rb', line 7 def initialize(sock, local_settings = {}) require "http/parser" @_headers = nil @_body = "" @_http_parser = setup_parser @sock = sock super(@sock.method(:write), local_settings) end |
Instance Attribute Details
#sock ⇒ Object (readonly)
Returns the value of attribute sock.
5 6 7 |
# File 'lib/plum/http_connection.rb', line 5 def sock @sock end |
Instance Method Details
#close ⇒ Object
Closes the socket.
24 25 26 27 |
# File 'lib/plum/http_connection.rb', line 24 def close super @sock.close end |
#run ⇒ Object
Starts communication with the peer. It blocks until the io is closed, or reaches EOF.
17 18 19 20 21 |
# File 'lib/plum/http_connection.rb', line 17 def run while !@sock.closed? && !@sock.eof? self << @sock.readpartial(1024) end end |