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
lib/httpx/loggable.rb
Ruby
apache-2.0
237
master
1,735
# frozen_string_literal: true require "fiber" if RUBY_VERSION < "3.0.0" module HTTPX module Loggable COLORS = { black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37, }.freeze USE_DEBUG_LOG = ENV.key?("HTTPX_DEBUG") de...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/chainable.rb
Ruby
apache-2.0
237
master
3,104
# frozen_string_literal: true module HTTPX # Session mixin, implements most of the APIs that the users call. # delegates to a default session when extended. module Chainable %w[head get post put delete trace options connect patch].each do |meth| class_eval(<<-MOD, __FILE__, __LINE__ + 1) def #{...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder.rb
Ruby
apache-2.0
237
master
2,618
# frozen_string_literal: true module HTTPX module Transcoder module_function def normalize_keys(key, value, transcoder = self, &block) if value.respond_to?(:to_ary) if value.empty? block.call("#{key}[]") else value.to_ary.each do |element| transcoder.nor...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/buffer.rb
Ruby
apache-2.0
237
master
1,199
# frozen_string_literal: true require "forwardable" module HTTPX # Internal class to abstract a string buffer, by wrapping a string and providing the # minimum possible API and functionality required. # # buffer = Buffer.new(640) # buffer.full? #=> false # buffer << "aa" # buffer.capacit...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/punycode.rb
Ruby
apache-2.0
237
master
443
# frozen_string_literal: true module HTTPX module Punycode module_function begin require "idnx" def encode_hostname(hostname) Idnx.to_punycode(hostname) end rescue LoadError def encode_hostname(hostname) warn "#{hostname} cannot be converted to punycode. Install ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/session_extensions.rb
Ruby
apache-2.0
237
master
981
# frozen_string_literal: true module HTTPX unless ENV.keys.grep(/\Ahttps?_proxy\z/i).empty? proxy_session = plugin(:proxy) remove_const(:Session) const_set(:Session, proxy_session.class) # redefine the default options static var, which needs to # refresh options_class options = proxy_session...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/headers.rb
Ruby
apache-2.0
237
master
4,082
# frozen_string_literal: true module HTTPX class Headers class << self def new(headers = nil) return headers if headers.is_a?(self) super end end def initialize(headers = nil) if headers.nil? || headers.empty? @headers = headers.to_h return end ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/callbacks.rb
Ruby
apache-2.0
237
master
766
# frozen_string_literal: true module HTTPX module Callbacks def on(type, &action) callbacks(type) << action action end def once(type, &block) on(type) do |*args, &callback| block.call(*args, &callback) :delete end end def emit(type, *args) log { "em...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/request/body.rb
Ruby
apache-2.0
237
master
4,606
# frozen_string_literal: true module HTTPX # Implementation of the HTTP Request body as a delegator which iterates (responds to +each+) payload chunks. class Request::Body < SimpleDelegator class << self def new(_, options, body: nil, **params) if body.is_a?(self) # request derives its ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/adapters/webmock.rb
Ruby
apache-2.0
237
master
5,268
# frozen_string_literal: true module WebMock module HttpLibAdapters require "net/http/status" HTTP_REASONS = Net::HTTP::STATUS_CODES # # HTTPX plugin for webmock. # # Requests are "hijacked" at the session, before they're distributed to a connection. # module Plugin class << se...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/adapters/faraday.rb
Ruby
apache-2.0
237
master
8,583
# frozen_string_literal: true require "delegate" require "httpx" require "faraday" module Faraday class Adapter class HTTPX < Faraday::Adapter def initialize(app = nil, opts = {}, &block) @connection = @bind = nil super end module RequestMixin def build_connection(env)...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/adapters/datadog.rb
Ruby
apache-2.0
237
master
10,858
# frozen_string_literal: true require "datadog/tracing/contrib/integration" require "datadog/tracing/contrib/configuration/settings" require "datadog/tracing/contrib/patcher" module Datadog::Tracing module Contrib module HTTPX DATADOG_VERSION = defined?(::DDTrace) ? ::DDTrace::VERSION : ::Datadog::VERSION...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/adapters/sentry.rb
Ruby
apache-2.0
237
master
3,211
# frozen_string_literal: true require "sentry-ruby" module HTTPX::Plugins module Sentry module Tracer module_function def call(request) sentry_span = start_sentry_span return unless sentry_span set_sentry_trace_header(request, sentry_span) request.on(:response, &m...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/connection/http2.rb
Ruby
apache-2.0
237
master
14,302
# frozen_string_literal: true require "securerandom" require "http/2" module HTTPX class Connection::HTTP2 include Callbacks include Loggable MAX_CONCURRENT_REQUESTS = ::HTTP2::DEFAULT_MAX_CONCURRENT_STREAMS class Error < Error def initialize(id, error) super("stream #{id} closed wit...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/connection/http1.rb
Ruby
apache-2.0
237
master
11,155
# frozen_string_literal: true require "httpx/parser/http1" module HTTPX class Connection::HTTP1 include Callbacks include Loggable MAX_REQUESTS = 200 CRLF = "\r\n" UPCASED = { "www-authenticate" => "WWW-Authenticate", "http2-settings" => "HTTP2-Settings", "content-md5" => "Co...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/io/unix.rb
Ruby
apache-2.0
237
master
1,570
# frozen_string_literal: true module HTTPX class UNIX < TCP using URIExtensions attr_reader :path alias_method :host, :path def initialize(origin, path, options) @addresses = [] @hostname = origin.host @state = :idle @options = options @fallback_protocol = @options.fa...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/io/tcp.rb
Ruby
apache-2.0
237
master
5,803
# frozen_string_literal: true require "resolv" module HTTPX class TCP include Loggable using URIExtensions attr_reader :ip, :port, :addresses, :state, :interests alias_method :host, :ip def initialize(origin, addresses, options) @state = :idle @keep_open = false @addresses ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/io/udp.rb
Ruby
apache-2.0
237
master
1,226
# frozen_string_literal: true require "ipaddr" module HTTPX class UDP include Loggable def initialize(ip, port, options) @host = ip @port = port @io = UDPSocket.new(IPAddr.new(ip).family) @options = options end def to_io @io.to_io end def connect; end de...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/io/ssl.rb
Ruby
apache-2.0
237
master
5,104
# frozen_string_literal: true require "openssl" module HTTPX TLSError = OpenSSL::SSL::SSLError class SSL < TCP # rubocop:disable Style/MutableConstant TLS_OPTIONS = { alpn_protocols: %w[h2 http/1.1].freeze } # https://github.com/jruby/jruby-openssl/issues/284 # TODO: remove when dropping support ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/body.rb
Ruby
apache-2.0
237
master
1,017
# frozen_string_literal: true require "delegate" module HTTPX::Transcoder module Body class Error < HTTPX::Error; end module_function class Encoder < SimpleDelegator def initialize(body) body = body.open(File::RDONLY, encoding: Encoding::BINARY) if Object.const_defined?(:Pathname) && bod...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/json.rb
Ruby
apache-2.0
237
master
1,794
# frozen_string_literal: true require "forwardable" module HTTPX::Transcoder module JSON module_function JSON_REGEX = %r{ \b application/ # optional vendor specific type (?: # token as per https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 [!#$%&'*+\-.^_`|~0...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/form.rb
Ruby
apache-2.0
237
master
1,595
# frozen_string_literal: true require "forwardable" require "uri" require_relative "multipart" module HTTPX module Transcoder module Form module_function PARAM_DEPTH_LIMIT = 32 class Encoder extend Forwardable def_delegator :@raw, :to_s def_delegator :@raw, :to_str ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/gzip.rb
Ruby
apache-2.0
237
master
1,666
# frozen_string_literal: true require "zlib" module HTTPX module Transcoder module GZIP class Deflater < Transcoder::Deflater def initialize(body) @compressed_chunk = "".b @deflater = nil super end def deflate(chunk) @deflater ||= Zlib::Gzip...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/deflate.rb
Ruby
apache-2.0
237
master
961
# frozen_string_literal: true require "zlib" require_relative "utils/deflater" module HTTPX module Transcoder module Deflate class Deflater < Transcoder::Deflater def deflate(chunk) @deflater ||= Zlib::Deflate.new unless chunk.nil? chunk = @deflater.deflate(chunk) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/multipart.rb
Ruby
apache-2.0
237
master
1,041
# frozen_string_literal: true require_relative "multipart/encoder" require_relative "multipart/decoder" require_relative "multipart/part" require_relative "multipart/mime_type_detector" module HTTPX::Transcoder module Multipart module_function def multipart?(form_data) form_data.any? do |_, v| ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/chunker.rb
Ruby
apache-2.0
237
master
2,715
# frozen_string_literal: true require "forwardable" module HTTPX::Transcoder module Chunker class Error < HTTPX::Error; end CRLF = "\r\n".b class Encoder extend Forwardable def initialize(body) @raw = body end def each return enum_for(__method__) unless block_...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/utils/body_reader.rb
Ruby
apache-2.0
237
master
957
# frozen_string_literal: true require "stringio" module HTTPX module Transcoder class BodyReader def initialize(body) @body = if body.respond_to?(:read) body.rewind if body.respond_to?(:rewind) body elsif body.respond_to?(:each) body.enum_for(:each) el...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/utils/deflater.rb
Ruby
apache-2.0
237
master
1,406
# frozen_string_literal: true require_relative "body_reader" module HTTPX module Transcoder class Deflater attr_reader :content_type def initialize(body) @content_type = body.content_type @body = BodyReader.new(body) @closed = false end def bytesize buff...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/multipart/decoder.rb
Ruby
apache-2.0
237
master
4,173
# frozen_string_literal: true require "tempfile" require "delegate" module HTTPX module Transcoder module Multipart class FilePart < SimpleDelegator attr_reader :original_filename, :content_type def initialize(filename, content_type) @original_filename = filename @cont...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/multipart/encoder.rb
Ruby
apache-2.0
237
master
2,996
# frozen_string_literal: true module HTTPX module Transcoder::Multipart class Encoder attr_reader :bytesize def initialize(form) @boundary = ("-" * 21) << SecureRandom.hex(21) @part_index = 0 @buffer = "".b @form = form @bytesize = 0 @parts = to_parts...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/multipart/mime_type_detector.rb
Ruby
apache-2.0
237
master
1,962
# frozen_string_literal: true module HTTPX module Transcoder::Multipart module MimeTypeDetector module_function DEFAULT_MIMETYPE = "application/octet-stream" # inspired by https://github.com/shrinerb/shrine/blob/master/lib/shrine/plugins/determine_mime_type.rb if defined?(FileMagic) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/transcoder/multipart/part.rb
Ruby
apache-2.0
237
master
1,158
# frozen_string_literal: true module HTTPX module Transcoder::Multipart module Part module_function def call(value) # take out specialized objects of the way if value.respond_to?(:filename) && value.respond_to?(:content_type) && value.respond_to?(:read) return value, value....
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/query.rb
Ruby
apache-2.0
237
master
689
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for using the experimental QUERY HTTP method # # https://gitlab.com/os85/httpx/wikis/Query module Query def self.subplugins { retries: QueryRetries, } end module Ins...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/oauth.rb
Ruby
apache-2.0
237
master
8,844
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for managing an OAuth Session associated with the given session. # # The scope of OAuth support is limited to the `client_crendentials` and `refresh_token` grants. # # https://gitlab.com/os85/httpx/wikis/OA...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/tracing.rb
Ruby
apache-2.0
237
master
3,725
# frozen_string_literal: true module HTTPX::Plugins # # This plugin adds a simple interface to integrate request tracing SDKs. # # An example of such an integration is the datadog adapter. # # https://gitlab.com/os85/httpx/wikis/Tracing # module Tracing class Wrapper attr_reader :tracers ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/response_cache.rb
Ruby
apache-2.0
237
master
10,862
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for retrying requests when certain errors happen. # # https://gitlab.com/os85/httpx/wikis/Response-Cache # module ResponseCache CACHEABLE_VERBS = %w[GET HEAD].freeze CACHEABLE_STATUS_CODES = [20...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/proxy.rb
Ruby
apache-2.0
237
master
9,602
# frozen_string_literal: true module HTTPX class ProxyError < ConnectionError; end module Plugins # # This plugin adds support for proxies. It ships with support for: # # * HTTP proxies # * HTTPS proxies # * Socks4/4a proxies # * Socks5 proxies # # https://gitlab.com/os85/httpx...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/grpc.rb
Ruby
apache-2.0
237
master
8,815
# frozen_string_literal: true module HTTPX GRPCError = Class.new(Error) do attr_reader :status, :details, :metadata def initialize(status, details, metadata) @status = status @details = details @metadata = metadata super("GRPC error, code=#{status}, details=#{details}, metadata=#{met...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/circuit_breaker.rb
Ruby
apache-2.0
237
master
5,075
# frozen_string_literal: true module HTTPX module Plugins # # This plugin implements a circuit breaker around connection errors. # # https://gitlab.com/os85/httpx/wikis/Circuit-Breaker # module CircuitBreaker using URIExtensions def self.load_dependencies(*) require_relat...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/stream_bidi.rb
Ruby
apache-2.0
237
master
10,549
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for bidirectional HTTP/2 streams. # # https://gitlab.com/os85/httpx/wikis/StreamBidi # # It is required that the request body allows chunk to be buffered, (i.e., responds to +#<<(chunk)+). module Stream...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/auth.rb
Ruby
apache-2.0
237
master
5,030
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds a shim +authorization+ method to the session, which will fill # the HTTP Authorization header, and another, +bearer_auth+, which fill the "Bearer " prefix # in its value. # # https://gitlab.com/os85/httpx/wikis/Aut...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/ntlm_auth.rb
Ruby
apache-2.0
237
master
1,712
# frozen_string_literal: true module HTTPX module Plugins # # https://gitlab.com/os85/httpx/wikis/Auth#ntlm-auth # module NTLMAuth class << self def load_dependencies(klass) require_relative "auth/ntlm" klass.plugin(:auth) end def extra_options(optio...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/push_promise.rb
Ruby
apache-2.0
237
master
2,393
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for HTTP/2 Push responses. # # In order to benefit from this, requests are sent one at a time, so that # no push responses are received after corresponding request has been sent. # # https://gitlab.com/...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/persistent.rb
Ruby
apache-2.0
237
master
2,707
# frozen_string_literal: true module HTTPX module Plugins # This plugin implements a session that persists connections over the duration of the process. # # This will improve connection reuse in a long-running process. # # One important caveat to note is, although this session might not close con...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/ssrf_filter.rb
Ruby
apache-2.0
237
master
4,981
# frozen_string_literal: true module HTTPX class ServerSideRequestForgeryError < Error; end module Plugins # # This plugin adds support for preventing Server-Side Request Forgery attacks. # # https://gitlab.com/os85/httpx/wikis/Server-Side-Request-Forgery-Filter # module SsrfFilter m...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/internal_telemetry.rb
Ruby
apache-2.0
237
master
3,129
# frozen_string_literal: true module HTTPX module Plugins # # The InternalTelemetry plugin is for internal use only. It is therefore undocumented, and # its use is disencouraged, as API compatiblity will **not be guaranteed**. # # The gist of it is: when debug_level of logger is enabled to 3 or g...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/upgrade.rb
Ruby
apache-2.0
237
master
2,345
# frozen_string_literal: true module HTTPX module Plugins # # This plugin helps negotiating a new protocol from an HTTP/1.1 connection, via the # Upgrade header. # # https://gitlab.com/os85/httpx/wikis/Upgrade # module Upgrade class << self def configure(klass) kla...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/brotli.rb
Ruby
apache-2.0
237
master
2,042
# frozen_string_literal: true module HTTPX module Plugins module Brotli class Error < HTTPX::Error; end class Deflater < Transcoder::Deflater def initialize(body) @compressor = ::Brotli::Compressor.new super end def deflate(chunk) return @compre...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/stream.rb
Ruby
apache-2.0
237
master
5,831
# frozen_string_literal: true module HTTPX class StreamResponse attr_reader :request def initialize(request, session) @request = request @options = @request.options @session = session @response_enum = nil @buffered_chunks = [] end def each(&block) return enum_for...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/aws_sigv4.rb
Ruby
apache-2.0
237
master
8,140
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds AWS Sigv4 authentication. # # https://docs.aws.amazon.com/IAM/latest/UserGuide/signing-elements.html # # https://gitlab.com/os85/httpx/wikis/AWS-SigV4 # module AWSSigV4 Credentials = Struct.new(:usern...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/webdav.rb
Ruby
apache-2.0
237
master
2,703
# frozen_string_literal: true module HTTPX module Plugins # # This plugin implements convenience methods for performing WEBDAV requests. # # https://gitlab.com/os85/httpx/wikis/WebDav # module WebDav def self.configure(klass) klass.plugin(:xml) end module InstanceMe...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/content_digest.rb
Ruby
apache-2.0
237
master
6,789
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds `Content-Digest` headers to requests # and can validate these headers on responses # # https://datatracker.ietf.org/doc/html/rfc9530 # module ContentDigest class Error < HTTPX::Error; end # Error r...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/xml.rb
Ruby
apache-2.0
237
master
1,832
# frozen_string_literal: true module HTTPX module Plugins # # This plugin supports request XML encoding/response decoding using the nokogiri gem. # # https://gitlab.com/os85/httpx/wikis/XML # module XML MIME_TYPES = %r{\b(application|text)/(.+\+)?xml\b}.freeze module Transcoder ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/retries.rb
Ruby
apache-2.0
237
master
9,351
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for retrying requests when errors happen. # # It has a default max number of retries (see *MAX_RETRIES* and the *max_retries* option), # after which it will return the last response, error or not. It will **not...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/follow_redirects.rb
Ruby
apache-2.0
237
master
8,691
# frozen_string_literal: true module HTTPX class InsecureRedirectError < Error end module Plugins # # This plugin adds support for automatically following redirect (status 30X) responses. # # It has a default upper bound of followed redirects (see *MAX_REDIRECTS* and the *max_redirects* option),...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/h2c.rb
Ruby
apache-2.0
237
master
3,388
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for upgrading a plaintext HTTP/1.1 connection to HTTP/2 # (https://datatracker.ietf.org/doc/html/rfc7540#section-3.2) # # https://gitlab.com/os85/httpx/wikis/Connection-Upgrade#h2c # module H2C VA...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/rate_limiter.rb
Ruby
apache-2.0
237
master
1,784
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for retrying requests when the request: # # * is rate limited; # * when the server is unavailable (503); # * when a 3xx request comes with a "retry-after" value # # https://gitlab.com/os85/httpx/wik...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/fiber_concurrency.rb
Ruby
apache-2.0
237
master
4,741
# frozen_string_literal: true module HTTPX module Plugins # This plugin makes a session reuse the same selector across all fibers in a given thread. # # This enables integration with fiber scheduler implementations such as [async](https://github.com/async). # # # https://gitlab.com/os85/httpx/wik...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/callbacks.rb
Ruby
apache-2.0
237
master
4,027
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds suppoort for callbacks around the request/response lifecycle. # # https://gitlab.com/os85/httpx/-/wikis/Events # module Callbacks CALLBACKS = %i[ connection_opened connection_closed request_er...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/expect.rb
Ruby
apache-2.0
237
master
4,479
# frozen_string_literal: true module HTTPX module Plugins # # This plugin makes all HTTP/1.1 requests with a body send the "Expect: 100-continue". # # https://gitlab.com/os85/httpx/wikis/Expect#expect # module Expect EXPECT_TIMEOUT = 2 NOEXPECT_STORE_MUTEX = Thread::Mutex.new ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/aws_sdk_authentication.rb
Ruby
apache-2.0
237
master
2,972
# frozen_string_literal: true module HTTPX module Plugins # # This plugin applies AWS Sigv4 to requests, using the AWS SDK credentials and configuration. # # It requires the "aws-sdk-core" gem. # module AwsSdkAuthentication # Mock configuration, to be used only when resolving credential...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/cookies.rb
Ruby
apache-2.0
237
master
2,940
# frozen_string_literal: true require "forwardable" module HTTPX module Plugins # # This plugin implements a persistent cookie jar for the duration of a session. # # https://gitlab.com/os85/httpx/wikis/Cookies # module Cookies def self.load_dependencies(*) require "httpx/plugin...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/digest_auth.rb
Ruby
apache-2.0
237
master
1,905
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds helper methods to implement HTTP Digest Auth (https://datatracker.ietf.org/doc/html/rfc7616) # # https://gitlab.com/os85/httpx/wikis/Auth#digest-auth # module DigestAuth class << self def extra_option...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/basic_auth.rb
Ruby
apache-2.0
237
master
697
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds helper methods to implement HTTP Basic Auth (https://datatracker.ietf.org/doc/html/rfc7617) # # https://gitlab.com/os85/httpx/wikis/Auth#basic-auth # module BasicAuth class << self def load_dependenci...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/upgrade/h2.rb
Ruby
apache-2.0
237
master
1,710
# frozen_string_literal: true module HTTPX module Plugins # # This plugin adds support for upgrading an HTTP/1.1 connection to HTTP/2 # via an Upgrade: h2 response declaration # # https://gitlab.com/os85/httpx/wikis/Connection-Upgrade#h2 # module H2 class << self def extra_o...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/proxy/socks5.rb
Ruby
apache-2.0
237
master
5,413
# frozen_string_literal: true module HTTPX class Socks5Error < ProxyError; end module Plugins module Proxy module Socks5 VERSION = 5 NOAUTH = 0 PASSWD = 2 NONE = 0xff CONNECT = 1 IPV4 = 1 DOMAIN = 3 IPV6 = 4 SUCCESS = 0 E...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/proxy/socks4.rb
Ruby
apache-2.0
237
master
3,542
# frozen_string_literal: true require "resolv" require "ipaddr" module HTTPX class Socks4Error < ProxyError; end module Plugins module Proxy module Socks4 VERSION = 4 CONNECT = 1 GRANTED = 0x5A PROTOCOLS = %w[socks4 socks4a].freeze Error = Socks4Error c...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/proxy/ssh.rb
Ruby
apache-2.0
237
master
2,896
# frozen_string_literal: true require "httpx/plugins/proxy" module HTTPX module Plugins module Proxy module SSH class << self def load_dependencies(*) require "net/ssh/gateway" end end module OptionsMethods private def option_pr...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/proxy/http.rb
Ruby
apache-2.0
237
master
7,180
# frozen_string_literal: true module HTTPX module Plugins module Proxy module HTTP class << self def extra_options(options) options.merge(supported_proxy_protocols: options.supported_proxy_protocols + %w[http]) end end module InstanceMethods ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/auth/basic.rb
Ruby
apache-2.0
237
master
376
# frozen_string_literal: true require "httpx/base64" module HTTPX module Plugins module Authentication class Basic def initialize(user, password, **) @user = user @password = password end def authenticate(*) "Basic #{Base64.strict_encode64("#{@user}:#...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/auth/ntlm.rb
Ruby
apache-2.0
237
master
797
# frozen_string_literal: true require "httpx/base64" require "ntlm" module HTTPX module Plugins module Authentication class Ntlm def initialize(user, password, domain: nil) @user = user @password = password @domain = domain end def can_authenticate?(a...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/auth/digest.rb
Ruby
apache-2.0
237
master
3,989
# frozen_string_literal: true require "time" require "securerandom" require "digest" module HTTPX module Plugins module Authentication class Digest class Error < Error end def initialize(user, password, hashed: false, **) @user = user @password = password ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/auth/socks5.rb
Ruby
apache-2.0
237
master
446
# frozen_string_literal: true module HTTPX module Plugins module Authentication class Socks5 def initialize(user, password, **) @user = user @password = password end def can_authenticate?(*) @user && @password end def authenticate(*) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/circuit_breaker/circuit.rb
Ruby
apache-2.0
237
master
2,715
# frozen_string_literal: true module HTTPX module Plugins::CircuitBreaker # # A circuit is assigned to a given absoolute url or origin. # # It sets +max_attempts+, the number of attempts the circuit allows, before it is opened. # It sets +reset_attempts_in+, the time a circuit stays open at most,...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/circuit_breaker/circuit_store.rb
Ruby
apache-2.0
237
master
1,290
# frozen_string_literal: true module HTTPX::Plugins::CircuitBreaker using HTTPX::URIExtensions class CircuitStore def initialize(options) @circuits = Hash.new do |h, k| h[k] = Circuit.new( options.circuit_breaker_max_attempts, options.circuit_breaker_reset_attempts_in, ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/response_cache/file_store.rb
Ruby
apache-2.0
237
master
3,615
# frozen_string_literal: true require "pathname" module HTTPX::Plugins module ResponseCache # Implementation of a file system based cache store. # # It stores cached responses in a file under a directory pointed by the +dir+ # variable (defaults to the default temp directory from the OS), in a custo...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/response_cache/store.rb
Ruby
apache-2.0
237
master
731
# frozen_string_literal: true module HTTPX::Plugins module ResponseCache # Implementation of a thread-safe in-memory cache store. class Store def initialize @store = {} @store_mutex = Thread::Mutex.new end def clear @store_mutex.synchronize { @store.clear } en...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/cookies/cookie.rb
Ruby
apache-2.0
237
master
5,662
# frozen_string_literal: true module HTTPX module Plugins::Cookies # The HTTP Cookie. # # Contains the single cookie info: name, value and attributes. class Cookie include Comparable # Maximum number of bytes per cookie (RFC 6265 6.1 requires 4096 at # least) MAX_LENGTH = 409...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/cookies/jar.rb
Ruby
apache-2.0
237
master
5,773
# frozen_string_literal: true module HTTPX module Plugins::Cookies # The Cookie Jar # # It stores and manages cookies for a session, such as i.e. evicting when expired, access methods, or # initialization from parsing `Set-Cookie` HTTP header values. # # It closely follows the [CookieStore AP...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/cookies/set_cookie_parser.rb
Ruby
apache-2.0
237
master
3,758
# frozen_string_literal: true require "strscan" require "time" module HTTPX module Plugins::Cookies module SetCookieParser # Whitespace. RE_WSP = /[ \t]+/.freeze # A pattern that matches a cookie name or attribute name which may # be empty, capturing trailing whitespace. RE_NAME =...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/grpc/grpc_encoding.rb
Ruby
apache-2.0
237
master
2,057
# frozen_string_literal: true module HTTPX module Transcoder module GRPCEncoding class Deflater extend Forwardable attr_reader :content_type def initialize(body, compressed:) @content_type = body.content_type @body = BodyReader.new(body) @compressed =...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/grpc/message.rb
Ruby
apache-2.0
237
master
1,393
# frozen_string_literal: true module HTTPX module Plugins module GRPC # Encoding module for GRPC responses # # Can encode and decode grpc messages. module Message module_function # decodes a unary grpc response def unary(response) verify_status(response)...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/plugins/grpc/call.rb
Ruby
apache-2.0
237
master
1,391
# frozen_string_literal: true module HTTPX module Plugins module GRPC # Encapsulates call information class Call attr_writer :decoder def initialize(response) @response = response @decoder = ->(z) { z } @consumed = false @grpc_response = nil ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/entry.rb
Ruby
apache-2.0
237
master
679
# frozen_string_literal: true require "ipaddr" module HTTPX module Resolver class Entry < SimpleDelegator attr_reader :address def self.convert(address) new(address, rescue_on_convert: true) end def initialize(address, expires_in = Float::INFINITY, rescue_on_convert: false) ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/https.rb
Ruby
apache-2.0
237
master
10,180
# frozen_string_literal: true require "resolv" require "uri" require "forwardable" require "httpx/base64" module HTTPX # Implementation of a DoH name resolver (https://www.youtube.com/watch?v=unMXvnY2FNM). # It wraps an HTTPX::Connection object which integrates with the main session in the # same manner as othe...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/system.rb
Ruby
apache-2.0
237
master
7,309
# frozen_string_literal: true require "resolv" module HTTPX # Implementation of a synchronous name resolver which relies on the system resolver, # which is lib'c getaddrinfo function (abstracted in ruby via Addrinfo.getaddrinfo). # # Its main advantage is relying on the reference implementation for name resol...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/cache.rb
Ruby
apache-2.0
237
master
899
# frozen_string_literal: true require "httpx/resolver/cache/base" require "httpx/resolver/cache/memory" module HTTPX::Resolver # The internal resolvers cache adapters are defined under this namespace. # # Adapters must comply with the Resolver Cache Adapter API and implement the following methods: # # * #re...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/native.rb
Ruby
apache-2.0
237
master
16,154
# frozen_string_literal: true require "forwardable" require "resolv" module HTTPX # Implements a pure ruby name resolver, which abides by the Selectable API. # It delegates DNS payload encoding/decoding to the +resolv+ stlid gem. # class Resolver::Native < Resolver::Resolver extend Forwardable using ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/multi.rb
Ruby
apache-2.0
237
master
2,310
# frozen_string_literal: true require "forwardable" require "resolv" module HTTPX class Resolver::Multi attr_reader :resolvers, :options def initialize(resolver_type, options) @current_selector = @current_session = nil @options = options @resolver_options = @options.resolver_options ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/resolver.rb
Ruby
apache-2.0
237
master
5,799
# frozen_string_literal: true require "resolv" module HTTPX # Base class for all internal internet name resolvers. It handles basic blocks # from the Selectable API. # class Resolver::Resolver include Loggable using ArrayExtensions::Intersect RECORD_TYPES = { Socket::AF_INET6 => Resolv::DN...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/cache/memory.rb
Ruby
apache-2.0
237
master
958
# frozen_string_literal: true module HTTPX module Resolver::Cache # Implementation of a thread-safe in-memory LRU resolver cache. class Memory < Base def initialize super @hostnames = [] @lookups = Hash.new { |h, k| h[k] = [] } @lookup_mutex = Thread::Mutex.new end...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/resolver/cache/base.rb
Ruby
apache-2.0
237
master
3,755
# frozen_string_literal: true require "resolv" module HTTPX module Resolver::Cache # Base class of the Resolver Cache adapter implementations. # # While resolver caches are not required to inherit from this class, it nevertheless provides # common useful functions for desired functionality, such as ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/response/buffer.rb
Ruby
apache-2.0
237
master
2,842
# frozen_string_literal: true require "delegate" require "stringio" require "tempfile" module HTTPX # wraps and delegates to an internal buffer, which can be a StringIO or a Tempfile. class Response::Buffer < SimpleDelegator attr_reader :buffer protected :buffer # initializes buffer with the +thresho...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/response/body.rb
Ruby
apache-2.0
237
master
5,832
# frozen_string_literal: true module HTTPX # Implementation of the HTTP Response body as a buffer which implements the IO writer protocol # (for buffering the response payload), the IO reader protocol (for consuming the response payload), # and can be iterated over (via #each, which yields the payload in chunks)...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
lib/httpx/parser/http1.rb
Ruby
apache-2.0
237
master
5,253
# frozen_string_literal: true module HTTPX module Parser class Error < Error; end class HTTP1 VERSIONS = %w[1.0 1.1].freeze attr_reader :status_code, :http_version, :headers def initialize(observer) @observer = observer @state = :idle @buffer = "".b @heade...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
standalone_tests/multipart_mimemagic_test.rb
Ruby
apache-2.0
237
master
720
# frozen_string_literal: true require "mimemagic" require "test_helper" require "spy" require "support/http_helpers" require "support/minitest_extensions" class MultipartMimemagicTest < Minitest::Test include HTTPHelpers def test_plugin_multipart_mimemagic_file_upload assert defined?(MimeMagic) mimemagi...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
standalone_tests/system_resolver_timeout_test.rb
Ruby
apache-2.0
237
master
1,669
# frozen_string_literal: true require "test_helper" require "support/http_helpers" require "support/minitest_extensions" class SystemResolverTimeoutTest < Minitest::Test include HTTPHelpers # this test mocks an unresponsive DNS server which doesn't return a DNS asnwer back. def test_resolver_system_timeout ...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
standalone_tests/json_oj_test.rb
Ruby
apache-2.0
237
master
806
# frozen_string_literal: true require "oj" require "test_helper" class ResponseOjTest < Minitest::Test include HTTPX def test_response_decoders json_response = Response.new(request, 200, "2.0", { "content-type" => "application/json" }) json_response << %({"a": "b"}) assert json_response.json == { "a"...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
standalone_tests/json_multi_json_test.rb
Ruby
apache-2.0
237
master
826
# frozen_string_literal: true require "multi_json" require "test_helper" class ResponseYajlTest < Minitest::Test include HTTPX def test_response_decoders json_response = Response.new(request, 200, "2.0", { "content-type" => "application/json" }) json_response << %({"a": "b"}) assert json_response.jso...
github
HoneyryderChuck/httpx
https://github.com/HoneyryderChuck/httpx
standalone_tests/multipart_marcel_test.rb
Ruby
apache-2.0
237
master
704
# frozen_string_literal: true require "marcel" require "test_helper" require "spy" require "support/http_helpers" require "support/minitest_extensions" class MultipartMarcelTest < Minitest::Test include HTTPHelpers def test_plugin_multipart_marcel_file_upload assert defined?(Marcel) marcel_spy = Spy.on(...