Class: Celluloid::Http::Connection
- Inherits:
-
Object
- Object
- Celluloid::Http::Connection
- Includes:
- IO
- Defined in:
- lib/celluloid-http/connection.rb
Instance Attribute Summary collapse
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
3 4 5 |
# File 'lib/celluloid-http/connection.rb', line 3 def socket @socket end |
Class Method Details
.open(host, port = 80) ⇒ Object
34 35 36 37 38 |
# File 'lib/celluloid-http/connection.rb', line 34 def self.open(host, port = 80) connection = self.new connection.open(host, port) connection end |
Instance Method Details
#close ⇒ Object
9 10 11 12 |
# File 'lib/celluloid-http/connection.rb', line 9 def close socket.close terminate end |
#open(host, port = 80) ⇒ Object
5 6 7 |
# File 'lib/celluloid-http/connection.rb', line 5 def open(host, port = 80) @socket = TCPSocket.new(host, port) end |
#response ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/celluloid-http/connection.rb', line 18 def response response = Http::Response.new until response.finished? begin chunk = socket.readpartial(4096) rescue EOFError # do nothing ensure response << chunk end end response end |
#send_request(request) ⇒ Object
14 15 16 |
# File 'lib/celluloid-http/connection.rb', line 14 def send_request(request) socket.write(request.to_s) end |