Method: HTTPX::Channel.by

Defined in:
lib/httpx/channel.rb

.by(uri, options) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/httpx/channel.rb', line 46

def by(uri, options)
  type = options.transport || begin
    case uri.scheme
    when "http"
      "tcp"
    when "https"
      "ssl"
    when "h2"
      options = options.merge(ssl: { alpn_protocols: %(h2) })
      "ssl"
    else
      raise UnsupportedSchemeError, "#{uri}: #{uri.scheme}: unsupported URI scheme"
    end
  end
  new(type, uri, options)
end