Class: Plum::HTTPConnection

Inherits:
Connection show all
Defined in:
lib/plum/http_connection.rb

Constant Summary

Constants inherited from Connection

Connection::CLIENT_CONNECTION_PREFACE, Connection::DEFAULT_SETTINGS

Instance Attribute Summary collapse

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

Methods inherited from Connection

#receive, #reserve_stream

Methods included from ConnectionUtils

#goaway, #ping, #push_enabled?, #settings

Methods included from FlowControl

#send, #window_update

Methods included from EventEmitter

#callback, #on

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

#sockObject (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

#closeObject

Closes the socket.



24
25
26
27
# File 'lib/plum/http_connection.rb', line 24

def close
  super
  @sock.close
end

#runObject

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