Sha256: 257b521500601abaea9ee03c12e687d96fb6d8ac39f8da7740bd5231a7883bc2
Contents?: true
Size: 1.19 KB
Versions: 25
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require "forwardable" module HTTPX class UNIX < TCP extend Forwardable def_delegator :@uri, :port, :scheme def initialize(uri, addresses, options) @uri = uri @addresses = addresses @state = :idle @options = Options.new(options) @path = @options.transport_options[:path] @fallback_protocol = @options.fallback_protocol if @options.io @io = case @options.io when Hash @options.io[@path] else @options.io end unless @io.nil? @keep_open = true @state = :connected end end @io ||= build_socket end def hostname @uri.host end def connect return unless closed? begin if @io.closed? transition(:idle) @io = build_socket end @io.connect_nonblock(Socket.sockaddr_un(@path)) rescue Errno::EISCONN end transition(:connected) rescue Errno::EINPROGRESS, Errno::EALREADY, ::IO::WaitReadable end private def build_socket Socket.new(Socket::PF_UNIX, :STREAM, 0) end end end
Version data entries
25 entries across 25 versions & 1 rubygems