Class: Net::SocketHttp

Inherits:
HTTP
  • Object
show all
Defined in:
lib/cangrejo/net/socket_http.rb

Overview

Overrides the connect method to simply connect to a unix domain socket.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_socket_path, _dummy = nil) ⇒ SocketHttp

URI should be a relative URI giving the path on the HTTP server.

socket_path is the filesystem path to the socket the server is listening to.


10
11
12
13
# File 'lib/cangrejo/net/socket_http.rb', line 10

def initialize(_socket_path, _dummy=nil)
  @socket_path = _socket_path
  super
end

Instance Attribute Details

#socket_pathObject (readonly)

Returns the value of attribute socket_path.



6
7
8
# File 'lib/cangrejo/net/socket_http.rb', line 6

def socket_path
  @socket_path
end

Instance Method Details

#addr_portObject

Override to prevent errors concatenating relative URI objects.



22
23
24
# File 'lib/cangrejo/net/socket_http.rb', line 22

def addr_port
  File.basename(socket_path)
end

#connectObject

Create the socket object.



16
17
18
19
# File 'lib/cangrejo/net/socket_http.rb', line 16

def connect
  @socket = Net::BufferedIO.new UNIXSocket.new socket_path
  on_connect
end