source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/xml.rb
Ruby
apache-2.0
237
master
1,222
# frozen_string_literal: true require "nokogiri" module Requests module Plugins module XML def test_plugin_xml_request_body_document uri = build_uri("/post") response = HTTPX.plugin(:xml).post(uri, xml: Nokogiri::XML("<xml></xml>")) verify_status(response, 200) body = json_...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/expect.rb
Ruby
apache-2.0
237
master
2,871
# frozen_string_literal: true module Requests module Plugins module Expect def test_plugin_expect_100_form_params uri = build_uri("/post") response = HTTPX.plugin(:expect).post(uri, form: { "foo" => "bar" }) verify_status(response, 200) body = json_body(response) ver...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/upgrade.rb
Ruby
apache-2.0
237
master
2,093
# frozen_string_literal: true module Requests module Plugins module Upgrade def test_plugin_upgrade_h2 return unless origin.start_with?("https://") start_test_servlet(H2Upgrade, alpn_protocols: %w[http/1.1 h2]) do |server| http = HTTPX.plugin(SessionWithPool) http = ht...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/h2c.rb
Ruby
apache-2.0
237
master
1,422
# frozen_string_literal: true module Requests module Plugins module H2C def test_plugin_h2c HTTPX.plugin(SessionWithPool).plugin(:h2c).wrap do |session| uri = build_uri("/get") request = session.build_request("GET", uri) request2 = session.build_request("GET", uri) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/follow_redirects.rb
Ruby
apache-2.0
237
master
7,479
# frozen_string_literal: true module Requests module Plugins module FollowRedirects def test_plugin_follow_redirects no_redirect_response = HTTPX.get(redirect_uri) verify_status(no_redirect_response, 302) verify_header(no_redirect_response.headers, "location", redirect_location) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/retries.rb
Ruby
apache-2.0
237
master
12,136
# frozen_string_literal: true module Requests module Plugins module Retries def test_plugin_retries no_retries_session = HTTPX.plugin(RequestInspector).with(timeout: { request_timeout: 3 }) no_retries_response = no_retries_session.get(build_uri("/delay/10")) verify_error_response(no...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/auth.rb
Ruby
apache-2.0
237
master
9,251
# frozen_string_literal: true module Requests module Plugins module Authentication def test_plugin_auth get_uri = build_uri("/get") session = HTTPX.plugin(:auth) response = session.authorization("TOKEN").get(get_uri) verify_status(response, 200) body = json_body(res...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/push_promise.rb
Ruby
apache-2.0
237
master
1,446
# frozen_string_literal: true module Requests module Plugins module PushPromise def test_plugin_no_push_promise html, css = HTTPX.get(push_html_uri, push_css_uri, max_concurrent_requests: 1, http2_settings: { settings_enable_push: 1 }) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/brotli.rb
Ruby
apache-2.0
237
master
2,299
# frozen_string_literal: true module Requests module Plugins module Brotli def test_brotli session = HTTPX.plugin(:brotli) response = session.get("http://nghttp2.org/httpbin/brotli") if (response.respond_to?(:status) && response.status.between?(502, 504)) || (response.re...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/stream.rb
Ruby
apache-2.0
237
master
5,992
# frozen_string_literal: true module Requests module Plugins module Stream include FiberSchedulerTestHelpers def test_plugin_stream session = HTTPX.plugin(:stream) uri = build_uri("/get") no_stream_response = session.get(uri) stream_response = session.get(uri, strea...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/aws_authentication.rb
Ruby
apache-2.0
237
master
2,297
# frozen_string_literal: true require "aws-sdk-s3" module Requests module Plugins module AWSAuthentication AWS_URI = ENV.fetch("AMZ_HOST", "aws:9090") AWSS_URI = ENV.fetch("AMZS_HOST", "aws:9191") def test_plugin_aws_authentication_put_object begin s3_client = Aws::S3::Clien...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/cookies.rb
Ruby
apache-2.0
237
master
5,772
# frozen_string_literal: true module Requests module Plugins module Cookies using HTTPX::URIExtensions def test_plugin_cookies_get session = HTTPX.plugin(:cookies) response = session.get(cookies_uri) body = json_body(response) assert body.key?("cookies") asser...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/webdav.rb
Ruby
apache-2.0
237
master
4,188
# frozen_string_literal: true module Requests module Plugins module WebDav def test_plugin_webdav_mkcol # put file webdav_client.delete("/mkcol_dir_test/") response = webdav_client.mkcol("/mkcol_dir_test/") verify_status(response, 201) end def test_plugin_webda...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/requests/plugins/content_digest.rb
Ruby
apache-2.0
237
master
4,655
# frozen_string_literal: true module Requests module Plugins module ContentDigest IGNORE_MISSING_HEADER = ->(res) { res.headers.key?("content-digest") } def test_content_digest_missing_no_validation start_test_servlet(ContentDigestServer) do |server| http = HTTPX.plugin(:content_di...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/dns_same_relative_name.rb
Ruby
apache-2.0
237
master
421
# frozen_string_literal: true require "resolv" require_relative "test" # from https://gist.github.com/peterc/1425383 class DNSSameRelativeName < TestDNSResolver private def question_section(query) domain = extract_domain(query) section = [domain.size].pack("C") << domain.b << query[-5..-1] # Use po...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/expect100.rb
Ruby
apache-2.0
237
master
770
# frozen_string_literal: true require_relative "test" class Expect100Server < TestServer class DelayedExpect100App < WEBrick::HTTPServlet::AbstractServlet def do_POST(req, res) # rubocop:disable Naming/MethodName query = WEBrick::HTTPUtils.parse_query(req.query_string) delay = (query["delay"] || 1)....
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/dns_serv_fail_once.rb
Ruby
apache-2.0
237
master
434
# frozen_string_literal: true require "resolv" require_relative "test" # from https://gist.github.com/peterc/1425383 class DNSServFailOnce < TestDNSResolver attr_reader :failed def initialize(*, **) super @failed = Hash.new(false) end private def dns_response(query) domain = extract_domain(q...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/oauth_provider.rb
Ruby
apache-2.0
237
master
3,228
# frozen_string_literal: true require "json" require "uri" require_relative "test" class OAuthProviderServer < TestServer attr_reader :metadata class Token < WEBrick::HTTPServlet::AbstractServlet def do_POST(req, res) # rubocop:disable Naming/MethodName body = URI.decode_www_form(req.body).to_h u...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/no_content_length.rb
Ruby
apache-2.0
237
master
1,298
# frozen_string_literal: true require "zlib" require "stringio" require_relative "test" class NoContentLengthServer < TestServer module NoContentLength def self.extended(obj) super obj.singleton_class.class_eval do alias_method(:setup_header_without_clength, :setup_header) alias_meth...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/cache.rb
Ruby
apache-2.0
237
master
417
# frozen_string_literal: true require_relative "test" class ResponseCacheServer < TestServer class NoCacheApp < WEBrick::HTTPServlet::AbstractServlet def do_GET(_req, res) # rubocop:disable Naming/MethodName res.status = 200 res.body = "no-cache" res["Cache-Control"] = "private, no-store" ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/misdirected.rb
Ruby
apache-2.0
237
master
695
# frozen_string_literal: true class MisdirectedServer < TestHTTP2Server attr_reader :frames def initialize super @server.ctx.alpn_select_cb = lambda(&:first) end private def handle_connection(conn, sock) case sock.alpn_protocol when "h2" super conn.on(:frame_received) do |_| ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/close_after_x_seconds.rb
Ruby
apache-2.0
237
master
1,054
# frozen_string_literal: true # it'll close the first stream immediately on first data chunk received class CloseAfterXThenDelaySeconds < TestHTTP2Server def initialize(seconds_to_close: 2, delay: nil, **kw) super(**kw) @timers = [] @delay = delay @sent_first = @can_delay = false @seconds_to_clos...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/upgrade.rb
Ruby
apache-2.0
237
master
502
# frozen_string_literal: true class H2Upgrade < TestHTTP2Server def buffer_to_socket(sock, data) return super unless @conns[sock].state == :waiting_magic && !data.start_with?("PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n") # assume HTTP/1.1 sock << "HTTP/1.1 200 OK\r\n" \ "Conten...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/socks5_with_none_server.rb
Ruby
apache-2.0
237
master
657
# frozen_string_literal: true class Sock5WithNoneServer attr_reader :origin def initialize @port = 0 @host = "localhost" @server = TCPServer.new(0) _, port, ip, _ = @server.addr @origin = URI::Generic.build(scheme: "socks5", host: ip, port: port) end def shutdown @server.close end...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/trailers.rb
Ruby
apache-2.0
237
master
890
# frozen_string_literal: true require_relative "test" class HTTPTrailersServer < TestServer module Trailers def self.extended(obj) super obj.singleton_class.class_eval do alias_method(:send_body_without_trailers, :send_body) alias_method(:send_body, :send_body_with_trailers) e...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/by_ip_cert_server.rb
Ruby
apache-2.0
237
master
644
# frozen_string_literal: true require_relative "test" class ByIpCertServer < TestServer CERTS_DIR = File.expand_path("../ci/certs", __dir__) def initialize cert = OpenSSL::X509::Certificate.new(File.read(File.join(CERTS_DIR, "localhost-server.crt"))) key = OpenSSL::PKey.read(File.read(File.join(CERTS_DIR...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/slow_reader.rb
Ruby
apache-2.0
237
master
1,100
# frozen_string_literal: true require "socket" class SlowReader def initialize @server = TCPServer.new("127.0.0.1", 0) @server.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVBUF, 5) @can_log = ENV.key?("HTTPX_DEBUG") end def origin _, sock, ip, _ = @server.addr "http://#{ip}:#{sock}" end ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/bidi_fail_after_data.rb
Ruby
apache-2.0
237
master
1,161
# frozen_string_literal: true require_relative "bidi" # BidiFailAfterData is a Bidi server that fails after receiving the first DATA frame. # This simulates a connection failure during active bidirectional streaming, # triggering the retry mechanism while the client is actively sending data. # # The sequence is: # 1....
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/proxy_redirector.rb
Ruby
apache-2.0
237
master
901
# frozen_string_literal: true require "webrick/httpproxy" require_relative "test" class ProxyServer < WEBrick::HTTPProxyServer def initialize(options = {}) super({ :BindAddress => "127.0.0.1", :Port => 0, :AccessLog => File.new(File::NULL), :Logger => Logger.new(File::NULL), }.merge(...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/bidi_fail_once.rb
Ruby
apache-2.0
237
master
1,110
# frozen_string_literal: true require_relative "bidi" # BidiFailOnce is a Bidi server that fails the first request after headers are sent. # This simulates a connection failure during a bidirectional streaming request, # triggering the retry mechanism. # # The sequence is: # 1. First stream: receives client headers, ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/dns_no_address.rb
Ruby
apache-2.0
237
master
202
# frozen_string_literal: true require "resolv" require_relative "test" # from https://gist.github.com/peterc/1425383 class DNSNoAddress < TestDNSResolver private def resolve(*) [] end end
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/dns_error.rb
Ruby
apache-2.0
237
master
222
# frozen_string_literal: true require_relative "test" # from https://gist.github.com/peterc/1425383 class DNSErrorServer < TestDNSResolver private def dns_response(query) dns_error_response(query, 4) end end
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/content_digest.rb
Ruby
apache-2.0
237
master
2,694
# frozen_string_literal: true require_relative "test" class ContentDigestServer < TestServer class NoDigestApp < WEBrick::HTTPServlet::AbstractServlet def do_GET(_req, res) # rubocop:disable Naming/MethodName res.status = 200 res.body = "{\"hello\": \"world\"}" res["Content-Type"] = "applicati...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/settings_timeout.rb
Ruby
apache-2.0
237
master
332
# frozen_string_literal: true class SettingsTimeoutServer < TestHTTP2Server attr_reader :frames def initialize(**) super @frames = [] end private def handle_connection(conn, sock) conn.on(:frame_received) do |frame| @frames << frame end conn.on(:goaway) do sock.close en...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/ntlm.rb
Ruby
apache-2.0
237
master
1,164
# frozen_string_literal: true require_relative "test" class NTLMServer < TestServer class NTLMApp < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) # rubocop:disable Naming/MethodName if req["Authorization"] =~ /^NTLM (.*)/ authorization = Regexp.last_match(1).unpack("m*")[0] # rubocop:...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/keep_alive.rb
Ruby
apache-2.0
237
master
2,283
# frozen_string_literal: true require_relative "test" class KeepAliveServer < TestServer class KeepAliveApp < WEBrick::HTTPServlet::AbstractServlet def do_GET(_req, res) # rubocop:disable Naming/MethodName res.status = 200 res["Connection"] = "Keep-Alive" res["Content-Type"] = "application/jso...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/slow_dns.rb
Ruby
apache-2.0
237
master
621
# frozen_string_literal: true require "resolv" require_relative "test" # from https://gist.github.com/peterc/1425383 class SlowDNSServer < TestDNSResolver def initialize(timeout, *args, hostname: nil, als: nil, **kwargs) @timeout = timeout @hostname = hostname @alias = als super(*args, **kwargs) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/test.rb
Ruby
apache-2.0
237
master
8,517
# frozen_string_literal: true require "logger" class TestServer < WEBrick::HTTPServer def initialize(options = {}) super({ :BindAddress => "127.0.0.1", :Port => 0, :AccessLog => File.new(File::NULL), :Logger => Logger.new(File::NULL), # stretching due to some timeouts observed in C...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/close_stream_early.rb
Ruby
apache-2.0
237
master
794
# frozen_string_literal: true # it'll close the first stream immediately on first data chunk received class CloseStreamEarly < TestHTTP2Server attr_reader :chunks_per_stream def initialize(*) super @chunks_per_stream = Hash.new { |hs, k| hs[k] = [] } end private def handle_stream(conn, stream) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/redirector_307.rb
Ruby
apache-2.0
237
master
571
# frozen_string_literal: true require_relative "test" class Redirector307Server < TestServer class RedirectPostApp < WEBrick::HTTPServlet::AbstractServlet def do_POST(_req, res) # rubocop:disable Naming/MethodName res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, "/") end end class PostApp...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/digest.rb
Ruby
apache-2.0
237
master
833
# frozen_string_literal: true require_relative "test" class DigestServer < TestServer def get_passwd(user) @htpasswd.get_passwd("Wacky World", user, false) end def initialize(options = {}) algorithm = options.delete(:algorithm) super Tempfile.create("test_httpx_digest_auth") do |tmpfile| ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/support/servlets/bidi.rb
Ruby
apache-2.0
237
master
648
# frozen_string_literal: true require_relative "test" class Bidi < TestHTTP2Server private def handle_stream(_conn, stream) stream.on(:data) do |d| next if d.empty? # puts "SERVER: payload chunk: <<#{d}>>" data = JSON.parse(d) stream.data(JSON.dump({ processed: data }) << "\n", end_s...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
test/extensions/response_pattern_match.rb
Ruby
apache-2.0
237
master
2,653
# frozen_string_literal: true module ResponsePatternMatchTests include HTTPX def test_response_headers_deconstruct response = Response.new(request, 200, "2.0", { "host" => "google.com", "content-type" => "application/json" }) case response in [_, [*, ["content-type", content_type], *], _] assert...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/ractor.rb
Ruby
apache-2.0
237
master
209
# frozen_string_literal: true require "httpx" URL = "https://nghttp2.org/httpbin/get".freeze statuses = 4.times.map do Ractor.new do HTTPX.get(URL) end end.map(&:value).map(&:status) puts statuses
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/hackernews_pages.rb
Ruby
apache-2.0
237
master
3,320
require "httpx" require "oga" # Run script via: # > ruby examples/hackernews_pages.rb 5 # fetches all pages from the first 5 pages (of hackernews) # > ruby examples/hackernews_pages.rb 5 async # fetches all pages and all links from each of the first 5 pages using async scheduler # > ruby examples/hackernews_pages.rb 5...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/hackernews_frontpage.rb
Ruby
apache-2.0
237
master
1,619
require "httpx" require "oga" def print_status # thread backtraces Thread.list.each do |th| # next if th == Thread.current id = th.object_id puts "THREAD ID: #{id}" th.backtrace.each do |line| puts "\t#{id}: " + line end if th.backtrace puts "#" * 20 end end Signal.trap("INFO") { ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/s3.rb
Ruby
apache-2.0
237
master
564
require "httpx" FILE = "test/support/fixtures/image.jpg" BUCKET_URL = "https://httpx-tests.s3.eu-west-1.amazonaws.com" aws_httpx = HTTPX.plugin(:aws_sdk_authentication).aws_sdk_authentication(service: "s3") requests = (1..5).map{ |i| aws_httpx.build_request(:put, BUCKET_URL + "/image-#{i}", body: File.new(FILE)) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/proxy_get.rb
Ruby
apache-2.0
237
master
346
require "httpx" include HTTPX # supports HTTP/1 pipelining and HTTP/2 URLS = %w[http://nghttp2.org https://nghttp2.org/blog/]# * 3 client = HTTPX.plugin(:proxy) client = client.with_proxy(uri: "http://134.209.29.120:8080") responses = client.get(*URLS) puts responses.map(&:status) # response = client.get(URLS.firs...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/happy_eyeballs.rb
Ruby
apache-2.0
237
master
622
# # From https://ipv6friday.org/blog/2012/11/happy-testing/ # # The http server accessible via the test doamins is returning empty responses. # If you want to verify that the correct IP family is being used to establish the connection, # set HTTPX_DEBUG=2 # require "httpx" # URLS = %w[https://ipv4.test-ipv6.com] * 1 ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/reconnect.rb
Ruby
apache-2.0
237
master
207
require "httpx" # URLS = %w[https://nghttp2.org/httpbin/get] * 1 URLS = %w[http://www.google.com] * 1 HTTPX.plugin(:retries).wrap do |session| session.get(*URLS) sleep 60 * 5 session.get(*URLS) end
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/multiple_resolvers.rb
Ruby
apache-2.0
237
master
414
require "httpx" URLS = %w[https://nghttp2.org/httpbin/get] * 1 HTTPX.wrap do |client| res1 = client.get("https://nghttp2.org/httpbin/get", resolver_class: :native) res2 = client.get("https://www.google.com", resolver_class: :https) res3 = client.get("https://news.ycombinator.com/", resolver_class: :native) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/get.rb
Ruby
apache-2.0
237
master
367
require "httpx" if ARGV.empty? URLS = %w[https://nghttp2.org/httpbin/get] * 1 else URLS = ARGV end responses = HTTPX.get(*URLS) Array(responses).each do |res| puts "URI: #{res.uri}" case res when HTTPX::ErrorResponse puts "error: #{res.error}" puts res.error.backtrace else puts "STATUS: #{res...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/resolv_tcp.rb
Ruby
apache-2.0
237
master
1,224
# frozen_string_literal: true require "resolv" require "httpx" host = "127.0.0.11" port = 53 # srv_hostname = "aerserv-bc-us-east.bidswitch.net" record_type = Resolv::DNS::Resource::IN::A # # addresses = nil # # Resolv::DNS.open(nameserver: host) do |dns| # # require "pry-byebug"; binding.pry # # addresses = dn...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/stripe_faraday.rb
Ruby
apache-2.0
237
master
578
require "httpx/adapters/faraday" require "stripe" Stripe.api_key = "sk_test_123" Stripe.api_base = "https://localhost:12112" conn = Faraday.new do |builder| builder.use Faraday::Request::Multipart builder.use Faraday::Request::UrlEncoded builder.use Faraday::Response::RaiseError builder.adapter :httpx end co...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/post.rb
Ruby
apache-2.0
237
master
435
require "httpx" require "json" include HTTPX URLS = %w[http://nghttp2.org/httpbin/post] * 102 $HTTPX_DEBUG = true client = Session.new requests = URLS.map { |url| client.build_request(:post, url, json: {"bang" => "bang"}) } responses = client.request(*requests) responses.each do |res| puts "status: #{res.status...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
examples/resolv/srv_record.rb
Ruby
apache-2.0
237
master
591
require "httpx" host = "1.1.1.1" port = 53 hostname = "google.com" srv_hostname = "_https._tcp.#{hostname}" record_type = Resolv::DNS::Resource::IN::SRV addresses = nil Resolv::DNS.open(nameserver: host) do |dns| addresses = dns.getresources(srv_hostname, record_type) end # buffer = HTTPX::Resolver.encode_dns_que...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration/altsvc.rb
Ruby
apache-2.0
237
master
220
# frozen_string_literal: true require "httpx" URL = "https://blog.alteroot.org" # URL = "https://www.google.com/" HTTPX.with(max_concurrent_requests: 1) do |client| puts client.get(URL, URL, URL).map(&:status) end
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration/coalescing.rb
Ruby
apache-2.0
237
master
209
require "httpx" URLS = %w[https://graph.facebook.com/ https://developers.facebook.com/] HTTPX.wrap do |http| URLS.each do |url| response = http.get(url) puts "Status: #{response.status}" end end
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration_tests/sentry_test.rb
Ruby
apache-2.0
237
master
4,735
# frozen_string_literal: true require "logger" require "stringio" require "sentry-ruby" require "test_helper" require "support/http_helpers" require "httpx/adapters/sentry" class SentryTest < Minitest::Test include HTTPHelpers DUMMY_DSN = "http://12345:67890@sentry.localdomain/sentry/42" def test_sentry_send_...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration_tests/datadog_test.rb
Ruby
apache-2.0
237
master
6,897
# frozen_string_literal: true begin # upcoming 2.0 require "datadog" rescue LoadError require "ddtrace" end require "test_helper" require "support/http_helpers" require "httpx/adapters/datadog" require_relative "datadog_helpers" class DatadogTest < Minitest::Test include HTTPHelpers include DatadogHelpers ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration_tests/webmock_test.rb
Ruby
apache-2.0
237
master
14,837
# frozen_string_literal: true require "webmock/minitest" require "httpx/adapters/webmock" require "test_helper" require "support/http_helpers" class WebmockTest < Minitest::Test include HTTPHelpers include FiberSchedulerTestHelpers MOCK_URL_HTTP = "http://www.example.com" MOCK_URL_HTTP_SAME_ORIGIN = "http://...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration_tests/datadog_helpers.rb
Ruby
apache-2.0
237
master
3,889
# frozen_string_literal: true module DatadogHelpers DATADOG_VERSION = defined?(DDTrace) ? DDTrace::VERSION : Datadog::VERSION ERROR_TAG = if Gem::Version.new(DATADOG_VERSION::STRING) >= Gem::Version.new("1.8.0") "error.message" else "error.msg" end private def verify_instrumented_request(status, ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
integration_tests/faraday_datadog_test.rb
Ruby
apache-2.0
237
master
6,168
# frozen_string_literal: true begin # upcoming 2.0 require "datadog" rescue LoadError require "ddtrace" end require "test_helper" require "support/http_helpers" require "httpx/adapters/faraday" require_relative "datadog_helpers" DATADOG_VERSION = defined?(DDTrace) ? DDTrace::VERSION : Datadog::VERSION class F...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
smoke_tests/happy_eyeballs_test.rb
Ruby
apache-2.0
237
master
634
# frozen_string_literal: true require "test_helper" require "support/http_helpers" # https://test-ipv6.com/ class HappyEyeballsTest < Minitest::Test include HTTPHelpers IPV6_HOST = "https://ipv6.test-ipv6.com" IPV4_HOST = "https://ipv4.test-ipv6.com" def test_happy_eyeballs_prefer_ipv6 response = HTTPX....
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_14_4_test.rb
Ruby
apache-2.0
237
master
1,830
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_0_14_4_Test < Minitest::Test include HTTPHelpers def test_http1_keep_alive_persistent_requests_failed_to_start_new_connection_after_max_requests_reached start_test_servlet(KeepAliveServer) do |server| uri = "#{...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_6_2_test.rb
Ruby
apache-2.0
237
master
1,427
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_6_2_Test < Minitest::Test include HTTPHelpers def test_recover_well_from_multiple_timeouts_on_persistent start_test_servlet(SlowDNSServer, 1, ttl: 3) do |slow_dns_server| session = HTTPX.plugin(SessionWithPoo...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_7_2_test.rb
Ruby
apache-2.0
237
master
2,176
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_7_2_Test < Minitest::Test include HTTPHelpers def test_prevent_window_updates_once_a_stream_peer_closed start_test_servlet(CloseStreamEarly) do |server| HTTPX.plugin(SessionWithPool) .plugin(Reques...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_22_2_test.rb
Ruby
apache-2.0
237
master
1,206
# frozen_string_literal: true require "test_helper" require "support/http_helpers" require "support/minitest_extensions" class Bug_0_22_2_Test < Minitest::Test include HTTPHelpers Plugin = Module.new do @connections = [] class << self attr_reader :connections end self::ConnectionMethods = ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_4_3_test.rb
Ruby
apache-2.0
237
master
2,121
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_4_3_Test < Minitest::Test include HTTPHelpers def test_persistent_do_not_exhaust_retry_on_eof_error start_test_servlet(KeepAlivePongThenCloseSocketServer) do |server| persistent_session = HTTPX.plugin(Session...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_14_5_test.rb
Ruby
apache-2.0
237
master
1,085
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_0_14_5_Test < Minitest::Test include HTTPHelpers def test_http2_post_with_concurrent_post_requests_with_large_payload_blocking post_uri = "https://#{httpbin}/post" HTTPX.wrap do |http| # this is necesary, s...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_14_1_test.rb
Ruby
apache-2.0
237
master
867
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_0_14_1_Test < Minitest::Test include HTTPHelpers def test_multipart_can_have_arbitrary_content_type uri = "https://#{httpbin}/post" response = HTTPX.post(uri, form: { image: { ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_7_5_test.rb
Ruby
apache-2.0
237
master
5,181
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_7_5_Test < Minitest::Test include HTTPHelpers module ConnectionErrorCounter module ConnectionMethods attr_reader :on_error_calls def initialize(*) super @on_error_calls = 0 end ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_5_1_test.rb
Ruby
apache-2.0
237
master
1,594
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_5_1_Test < Minitest::Test include HTTPHelpers include FiberSchedulerTestHelpers def test_persistent_fiber_scheduler_skipping_dns_query_and_hanging urls = %w[ https://www.google.com https://nghttp2.org...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_4_1_test.rb
Ruby
apache-2.0
237
master
2,021
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_4_1_Test < Minitest::Test include HTTPHelpers def test_persistent_get_first_then_fail_on_next_and_retry start_test_servlet(OnPingDisconnectServer) do |server| persistent_session = HTTPX.plugin(SessionWithPool...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_3_1_test.rb
Ruby
apache-2.0
237
master
795
# frozen_string_literal: true require "test_helper" require "support/http_helpers" require "webmock/minitest" require "httpx/adapters/webmock" class Bug_1_3_1_Test < Minitest::Test include HTTPHelpers def test_plugin_http_webmock_next_proxy exception_class = Class.new(IOError) stub_exception = stub_http_...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_1_1_test.rb
Ruby
apache-2.0
237
master
577
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_1_1_Test < Minitest::Test include HTTPHelpers def test_connection_callbacks_fire_setup_once uri = build_uri("/get") connected = 0 HTTPX.on_connection_opened { |*| connected += 1 } .on_connection_...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_15_3_test.rb
Ruby
apache-2.0
237
master
595
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_0_15_3_Test < Minitest::Test include HTTPHelpers def test_selectables_usage_in_selector_on_multiple_hosts feeds_urls = %w[ https://www.mikeperham.com/index.xml https://www.opennet.ru/opennews/opennews_min...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_14_3_test.rb
Ruby
apache-2.0
237
master
580
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_0_14_3_Test < Minitest::Test include HTTPHelpers def test_insecure_to_secure_redirect_was_carrying_connection_close_invalid_http2 insecure_uri = "http://www.nature.com/articles/nature10414" session = HTTPX.plugi...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_1_0_test.rb
Ruby
apache-2.0
237
master
667
# frozen_string_literal: true require "test_helper" require "support/http_helpers" require "support/minitest_extensions" class Bug_1_1_0_Test < Minitest::Test include HTTPHelpers def test_read_timeout_firing_too_soon_before_select timeout = { read_timeout: 2 } uri = build_uri("/get") begin re...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_24_1_test.rb
Ruby
apache-2.0
237
master
1,137
# frozen_string_literal: true require "webrick" require "webrick/httpproxy" require "test_helper" require "support/http_helpers" require "support/proxy_helper" require "support/minitest_extensions" class Bug_0_24_1_Test < Minitest::Test include HTTPHelpers include ProxyHelper Plugin = Module.new do @reques...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_0_14_2_test.rb
Ruby
apache-2.0
237
master
868
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_0_14_2_Test < Minitest::Test include HTTPHelpers def test_multipart_can_have_arbitrary_filename uri = "https://#{httpbin}/post" response = HTTPX.post(uri, form: { image: { ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_6_0_test.rb
Ruby
apache-2.0
237
master
974
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_6_1_Test < Minitest::Test include HTTPHelpers def test_retries_should_retry_on_goaway_cancel start_test_servlet(GoawayCancelErrorServer) do |server| http = HTTPX.plugin(SessionWithPool) .plu...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
regression_tests/bug_1_5_0_test.rb
Ruby
apache-2.0
237
master
1,994
# frozen_string_literal: true require "test_helper" require "support/http_helpers" class Bug_1_5_0_Test < Minitest::Test include HTTPHelpers def test_persistent_do_not_exhaust_retry_on_eof_error start_test_servlet(KeepAlivePongThenGoawayServer) do |server| persistent_session = HTTPX.plugin(SessionWithP...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx.rb
Ruby
apache-2.0
237
master
1,664
# frozen_string_literal: true require "httpx/version" # Top-Level Namespace # module HTTPX EMPTY = [].freeze EMPTY_HASH = {}.freeze # All plugins should be stored under this module/namespace. Can register and load # plugins. # module Plugins @plugins = {} @plugins_mutex = Thread::Mutex.new #...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/base64.rb
Ruby
apache-2.0
237
master
558
# frozen_string_literal: true if RUBY_VERSION < "3.3.0" require "base64" elsif !defined?(Base64) module HTTPX # require "base64" will not be a default gem after ruby 3.4.0 module Base64 module_function def decode64(str) str.unpack1("m") end def strict_encode64(bin) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/domain_name.rb
Ruby
apache-2.0
237
master
4,938
# frozen_string_literal: true # # domain_name.rb - Domain Name manipulation library for Ruby # # Copyright (C) 2011-2017 Akinori MUSHA, All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redist...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/session.rb
Ruby
apache-2.0
237
master
19,994
# frozen_string_literal: true module HTTPX # Class implementing the APIs being used publicly. # # HTTPX.get(..) #=> delegating to an internal HTTPX::Session object. # HTTPX.plugin(..).get(..) #=> creating an intermediate HTTPX::Session with plugin, then sending the GET request class Session include L...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/errors.rb
Ruby
apache-2.0
237
master
3,688
# frozen_string_literal: true module HTTPX # the default exception class for exceptions raised by HTTPX. class Error < StandardError; end class UnsupportedSchemeError < Error; end class ConnectionError < Error; end # Error raised when there was a timeout. Its subclasses allow for finer-grained # control...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/request.rb
Ruby
apache-2.0
237
master
9,972
# frozen_string_literal: true require "delegate" require "forwardable" module HTTPX # Defines how an HTTP request is handled internally, both in terms of making attributes accessible, # as well as maintaining the state machine which manages streaming the request onto the wire. class Request extend Forwardab...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/pmatch_extensions.rb
Ruby
apache-2.0
237
master
658
# frozen_string_literal: true module HTTPX module ResponsePatternMatchExtensions def deconstruct [@status, @headers, @body] end def deconstruct_keys(_keys) { status: @status, headers: @headers, body: @body } end end module ErrorResponsePatternMatchExtensions def deconstruct ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver.rb
Ruby
apache-2.0
237
master
2,915
# frozen_string_literal: true require "socket" require "resolv" module HTTPX module Resolver extend self RESOLVE_TIMEOUT = [2, 3].freeze require "httpx/resolver/entry" require "httpx/resolver/cache" require "httpx/resolver/resolver" require "httpx/resolver/system" require "httpx/resolve...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/connection.rb
Ruby
apache-2.0
237
master
30,466
# frozen_string_literal: true require "resolv" require "forwardable" require "httpx/io" require "httpx/buffer" module HTTPX # The Connection can be watched for IO events. # # It contains the +io+ object to read/write from, and knows what to do when it can. # # It defers connecting until absolutely necessary...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/response.rb
Ruby
apache-2.0
237
master
9,163
# frozen_string_literal: true require "objspace" require "stringio" require "tempfile" require "fileutils" require "forwardable" module HTTPX # Defines a HTTP response is handled internally, with a few properties exposed as attributes. # # It delegates the following methods to the corresponding HTTPX::Request: ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/options.rb
Ruby
apache-2.0
237
master
23,074
# frozen_string_literal: true module HTTPX # Contains a set of options which are passed and shared across from session to its requests or # responses. class Options BUFFER_SIZE = 1 << 14 WINDOW_SIZE = 1 << 14 # 16K MAX_BODY_THRESHOLD_SIZE = (1 << 10) * 112 # 112K KEEP_ALIVE_TIMEOUT = 20 SETTI...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/pool.rb
Ruby
apache-2.0
237
master
7,383
# frozen_string_literal: true require "httpx/selector" require "httpx/connection" require "httpx/connection/http2" require "httpx/connection/http1" require "httpx/resolver" module HTTPX class Pool using URIExtensions POOL_TIMEOUT = 5 # Sets up the connection pool with the given +options+, which can be...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/selector.rb
Ruby
apache-2.0
237
master
7,761
# frozen_string_literal: true require "io/wait" module HTTPX # # Implements the selector loop, where it registers and monitors "Selectable" objects. # # A Selectable object is an object which can calculate the **interests** (<tt>:r</tt>, <tt>:w</tt> or <tt>:rw</tt>, # respectively "read", "write" or "read-w...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/extensions.rb
Ruby
apache-2.0
237
master
942
# frozen_string_literal: true require "uri" module HTTPX module ArrayExtensions module Intersect refine Array do # Ruby 3.1 backport def intersect?(arr) if size < arr.size smaller = self else smaller, arr = arr, self end (arr ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/altsvc.rb
Ruby
apache-2.0
237
master
4,672
# frozen_string_literal: true require "strscan" module HTTPX module AltSvc # makes connections able to accept requests destined to primary service. module ConnectionMixin using URIExtensions H2_ALTSVC_SCHEMES = %w[https h2].freeze ALTSVC_IGNORE_IVARS = %i[@ssl].freeze def send(req...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/timers.rb
Ruby
apache-2.0
237
master
2,791
# frozen_string_literal: true module HTTPX class Timers def initialize @intervals = [] end def empty? @intervals.empty? end def after(interval_in_secs, cb = nil, &blk) callback = cb || blk raise Error, "timer must have a callback" unless callback # I'm assuming h...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/utils.rb
Ruby
apache-2.0
237
master
2,281
# frozen_string_literal: true module HTTPX module Utils using URIExtensions TOKEN = %r{[^\s()<>,;:\\"/\[\]?=]+}.freeze VALUE = /"(?:\\"|[^"])*"|#{TOKEN}/.freeze FILENAME_REGEX = /\s*filename=(#{VALUE})/.freeze FILENAME_EXTENSION_REGEX = /\s*filename\*=(#{VALUE})/.freeze module_function ...