Sha256: b21eb08dffc72e902cb62d182f8641d9dd9808ba21277c2247ef37f98da617f4
Contents?: true
Size: 1.19 KB
Versions: 4
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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
httpx-0.3.1 | lib/httpx/io/unix.rb |
httpx-0.3.0 | lib/httpx/io/unix.rb |
httpx-0.2.1 | lib/httpx/io/unix.rb |
httpx-0.2.0 | lib/httpx/io/unix.rb |