httpx 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/doc/release_notes/1_3_0.md +18 -0
- data/lib/httpx/adapters/datadog.rb +1 -1
- data/lib/httpx/adapters/webmock.rb +1 -1
- data/lib/httpx/connection/http1.rb +2 -2
- data/lib/httpx/connection/http2.rb +6 -6
- data/lib/httpx/connection.rb +6 -4
- data/lib/httpx/io/tcp.rb +1 -1
- data/lib/httpx/io/unix.rb +1 -1
- data/lib/httpx/options.rb +3 -7
- data/lib/httpx/plugins/aws_sigv4.rb +1 -1
- data/lib/httpx/plugins/cookies.rb +6 -6
- data/lib/httpx/plugins/follow_redirects.rb +22 -23
- data/lib/httpx/plugins/grpc.rb +2 -2
- data/lib/httpx/plugins/h2c.rb +1 -1
- data/lib/httpx/plugins/oauth.rb +1 -1
- data/lib/httpx/plugins/proxy/http.rb +2 -2
- data/lib/httpx/plugins/proxy/socks4.rb +1 -1
- data/lib/httpx/plugins/proxy/socks5.rb +1 -1
- data/lib/httpx/plugins/ssrf_filter.rb +1 -1
- data/lib/httpx/request/body.rb +37 -41
- data/lib/httpx/request.rb +36 -10
- data/lib/httpx/resolver/https.rb +1 -1
- data/lib/httpx/resolver/resolver.rb +1 -1
- data/lib/httpx/response.rb +2 -2
- data/lib/httpx/session.rb +20 -17
- data/lib/httpx/timers.rb +1 -1
- data/lib/httpx/version.rb +1 -1
- data/sig/chainable.rbs +2 -2
- data/sig/connection/http1.rbs +1 -1
- data/sig/connection/http2.rbs +16 -16
- data/sig/connection.rbs +2 -2
- data/sig/httpx.rbs +3 -3
- data/sig/io/tcp.rbs +1 -1
- data/sig/io/unix.rbs +1 -1
- data/sig/options.rbs +1 -13
- data/sig/plugins/follow_redirects.rbs +1 -1
- data/sig/plugins/proxy/http.rbs +3 -0
- data/sig/plugins/push_promise.rbs +3 -3
- data/sig/request/body.rbs +1 -3
- data/sig/request.rbs +2 -1
- data/sig/resolver/resolver.rbs +1 -1
- data/sig/response.rbs +1 -1
- data/sig/session.rbs +9 -6
- metadata +7 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 99138c8286fb426f6bd70a62357cbaf1b54f3ceb030f1ff3c78c9e2bffd8e75a
         | 
| 4 | 
            +
              data.tar.gz: 59a28cbadff4830ed047eba007b5f71455b5a8d6aa3e111cfb5897b82b1350fa
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 78b08826c993b9a2c5d1164a2bf6c7bb4123cb9599a1ddc44bd38b827c91da73abf4fee18ae39d67f9370834b3a8d04eb32999cf2c68f9fe654a0605e6d7ca5b
         | 
| 7 | 
            +
              data.tar.gz: 6b22a1e473abc7967314785f6fb517bf5d663d87951a7a2cba5855913a348b95dc50e2fddaa801fbcf25aef96b4d7d9b4e4d0dda8388696c0b628ba0c5dd7c1b
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            # 1.3.0
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            ## Dependencies
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            `http-2` v1.0.0 is replacing `http-2-next` as the HTTP/2 parser.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            `http-2-next` was forked from `http-2` 5 years ago; its improvements have been merged back to `http-2` recently though, so `http-2-next` willl therefore no longer be maintained.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ## Improvements
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Request-specific options (`:params`, `:form`, `:json` and `:xml`) are now separately kept by the request, which allows them to share `HTTPX::Options`, and reduce the number of copying / allocations.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            This means that `HTTPX::Options` will throw an error if you initialize an object which such keys; this should not happen, as this class is considered internal and you should not be using it directly.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ## Fixes
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            * support for the `datadog` gem v2.0.0 in its adapter has been unblocked, now that the gem has been released.
         | 
| 18 | 
            +
            * loading the `:cookies` plugin was making the `Session#build_request` private.
         | 
| @@ -142,7 +142,7 @@ module Datadog::Tracing | |
| 142 142 | 
             
                        @configuration ||= Datadog.configuration.tracing[:httpx, @request.uri.host]
         | 
| 143 143 | 
             
                      end
         | 
| 144 144 |  | 
| 145 | 
            -
                      if Gem::Version.new(DATADOG_VERSION::STRING) >= Gem::Version.new("2.0.0 | 
| 145 | 
            +
                      if Gem::Version.new(DATADOG_VERSION::STRING) >= Gem::Version.new("2.0.0")
         | 
| 146 146 | 
             
                        def propagate_trace_http(digest, headers)
         | 
| 147 147 | 
             
                          Datadog::Tracing::Contrib::HTTP.inject(digest, headers)
         | 
| 148 148 | 
             
                        end
         | 
| @@ -15,7 +15,7 @@ module HTTPX | |
| 15 15 | 
             
                attr_accessor :max_concurrent_requests
         | 
| 16 16 |  | 
| 17 17 | 
             
                def initialize(buffer, options)
         | 
| 18 | 
            -
                  @options =  | 
| 18 | 
            +
                  @options = options
         | 
| 19 19 | 
             
                  @max_concurrent_requests = @options.max_concurrent_requests || MAX_REQUESTS
         | 
| 20 20 | 
             
                  @max_requests = @options.max_requests
         | 
| 21 21 | 
             
                  @parser = Parser::HTTP1.new(self)
         | 
| @@ -146,7 +146,7 @@ module HTTPX | |
| 146 146 |  | 
| 147 147 | 
             
                  response << chunk
         | 
| 148 148 | 
             
                rescue StandardError => e
         | 
| 149 | 
            -
                  error_response = ErrorResponse.new(request, e | 
| 149 | 
            +
                  error_response = ErrorResponse.new(request, e)
         | 
| 150 150 | 
             
                  request.response = error_response
         | 
| 151 151 | 
             
                  dispatch
         | 
| 152 152 | 
             
                end
         | 
| @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            require "securerandom"
         | 
| 4 | 
            -
            require "http/2 | 
| 4 | 
            +
            require "http/2"
         | 
| 5 5 |  | 
| 6 6 | 
             
            module HTTPX
         | 
| 7 7 | 
             
              class Connection::HTTP2
         | 
| 8 8 | 
             
                include Callbacks
         | 
| 9 9 | 
             
                include Loggable
         | 
| 10 10 |  | 
| 11 | 
            -
                MAX_CONCURRENT_REQUESTS =  | 
| 11 | 
            +
                MAX_CONCURRENT_REQUESTS = ::HTTP2::DEFAULT_MAX_CONCURRENT_STREAMS
         | 
| 12 12 |  | 
| 13 13 | 
             
                class Error < Error
         | 
| 14 14 | 
             
                  def initialize(id, code)
         | 
| @@ -25,7 +25,7 @@ module HTTPX | |
| 25 25 | 
             
                attr_reader :streams, :pending
         | 
| 26 26 |  | 
| 27 27 | 
             
                def initialize(buffer, options)
         | 
| 28 | 
            -
                  @options =  | 
| 28 | 
            +
                  @options = options
         | 
| 29 29 | 
             
                  @settings = @options.http2_settings
         | 
| 30 30 | 
             
                  @pending = []
         | 
| 31 31 | 
             
                  @streams = {}
         | 
| @@ -111,7 +111,7 @@ module HTTPX | |
| 111 111 | 
             
                  end
         | 
| 112 112 | 
             
                  handle(request, stream)
         | 
| 113 113 | 
             
                  true
         | 
| 114 | 
            -
                rescue  | 
| 114 | 
            +
                rescue ::HTTP2::Error::StreamLimitExceeded
         | 
| 115 115 | 
             
                  @pending.unshift(request)
         | 
| 116 116 | 
             
                end
         | 
| 117 117 |  | 
| @@ -168,7 +168,7 @@ module HTTPX | |
| 168 168 | 
             
                end
         | 
| 169 169 |  | 
| 170 170 | 
             
                def init_connection
         | 
| 171 | 
            -
                  @connection =  | 
| 171 | 
            +
                  @connection = ::HTTP2::Client.new(@settings)
         | 
| 172 172 | 
             
                  @connection.on(:frame, &method(:on_frame))
         | 
| 173 173 | 
             
                  @connection.on(:frame_sent, &method(:on_frame_sent))
         | 
| 174 174 | 
             
                  @connection.on(:frame_received, &method(:on_frame_received))
         | 
| @@ -309,7 +309,7 @@ module HTTPX | |
| 309 309 | 
             
                  if error
         | 
| 310 310 | 
             
                    ex = Error.new(stream.id, error)
         | 
| 311 311 | 
             
                    ex.set_backtrace(caller)
         | 
| 312 | 
            -
                    response = ErrorResponse.new(request, ex | 
| 312 | 
            +
                    response = ErrorResponse.new(request, ex)
         | 
| 313 313 | 
             
                    request.response = response
         | 
| 314 314 | 
             
                    emit(:response, request, response)
         | 
| 315 315 | 
             
                  else
         | 
    
        data/lib/httpx/connection.rb
    CHANGED
    
    | @@ -48,6 +48,8 @@ module HTTPX | |
| 48 48 | 
             
                attr_accessor :family
         | 
| 49 49 |  | 
| 50 50 | 
             
                def initialize(uri, options)
         | 
| 51 | 
            +
                  @origins = [uri.origin]
         | 
| 52 | 
            +
                  @origin = Utils.to_uri(uri.origin)
         | 
| 51 53 | 
             
                  @options = Options.new(options)
         | 
| 52 54 | 
             
                  @type = initialize_type(uri, @options)
         | 
| 53 55 | 
             
                  @origins = [uri.origin]
         | 
| @@ -337,7 +339,7 @@ module HTTPX | |
| 337 339 | 
             
                      #
         | 
| 338 340 | 
             
                      loop do
         | 
| 339 341 | 
             
                        siz = @io.read(@window_size, @read_buffer)
         | 
| 340 | 
            -
                        log(level: 3, color: :cyan) { "IO READ: #{siz} bytes..." }
         | 
| 342 | 
            +
                        log(level: 3, color: :cyan) { "IO READ: #{siz} bytes... (wsize: #{@window_size}, rbuffer: #{@read_buffer.bytesize})" }
         | 
| 341 343 | 
             
                        unless siz
         | 
| 342 344 | 
             
                          ex = EOFError.new("descriptor closed")
         | 
| 343 345 | 
             
                          ex.set_backtrace(caller)
         | 
| @@ -504,7 +506,7 @@ module HTTPX | |
| 504 506 | 
             
                    when MisdirectedRequestError
         | 
| 505 507 | 
             
                      emit(:misdirected, request)
         | 
| 506 508 | 
             
                    else
         | 
| 507 | 
            -
                      response = ErrorResponse.new(request, ex | 
| 509 | 
            +
                      response = ErrorResponse.new(request, ex)
         | 
| 508 510 | 
             
                      request.response = response
         | 
| 509 511 | 
             
                      request.emit(:response, response)
         | 
| 510 512 | 
             
                    end
         | 
| @@ -530,7 +532,7 @@ module HTTPX | |
| 530 532 | 
             
                  connecting? && callbacks_for?(:connect_error) ? emit(:connect_error, error) : handle_error(error)
         | 
| 531 533 | 
             
                  @state = :closed
         | 
| 532 534 | 
             
                  emit(:close)
         | 
| 533 | 
            -
                rescue TLSError,  | 
| 535 | 
            +
                rescue TLSError, ::HTTP2::Error::ProtocolError, ::HTTP2::Error::HandshakeError => e
         | 
| 534 536 | 
             
                  # connect errors, exit gracefully
         | 
| 535 537 | 
             
                  handle_error(e)
         | 
| 536 538 | 
             
                  connecting? && callbacks_for?(:connect_error) ? emit(:connect_error, e) : handle_error(e)
         | 
| @@ -657,7 +659,7 @@ module HTTPX | |
| 657 659 | 
             
                def handle_error(error)
         | 
| 658 660 | 
             
                  parser.handle_error(error) if @parser && parser.respond_to?(:handle_error)
         | 
| 659 661 | 
             
                  while (request = @pending.shift)
         | 
| 660 | 
            -
                    response = ErrorResponse.new(request, error | 
| 662 | 
            +
                    response = ErrorResponse.new(request, error)
         | 
| 661 663 | 
             
                    request.response = response
         | 
| 662 664 | 
             
                    request.emit(:response, response)
         | 
| 663 665 | 
             
                  end
         | 
    
        data/lib/httpx/io/tcp.rb
    CHANGED
    
    
    
        data/lib/httpx/io/unix.rb
    CHANGED
    
    
    
        data/lib/httpx/options.rb
    CHANGED
    
    | @@ -91,7 +91,7 @@ module HTTPX | |
| 91 91 | 
             
                # :debug :: an object which log messages are written to (must respond to <tt><<</tt>)
         | 
| 92 92 | 
             
                # :debug_level :: the log level of messages (can be 1, 2, or 3).
         | 
| 93 93 | 
             
                # :ssl :: a hash of options which can be set as params of OpenSSL::SSL::SSLContext (see HTTPX::IO::SSL)
         | 
| 94 | 
            -
                # :http2_settings :: a hash of options to be passed to a  | 
| 94 | 
            +
                # :http2_settings :: a hash of options to be passed to a HTTP2::Connection (ex: <tt>{ max_concurrent_streams: 2 }</tt>)
         | 
| 95 95 | 
             
                # :fallback_protocol :: version of HTTP protocol to use by default in the absence of protocol negotiation
         | 
| 96 96 | 
             
                #                       like ALPN (defaults to <tt>"http/1.1"</tt>)
         | 
| 97 97 | 
             
                # :supported_compression_formats :: list of compressions supported by the transcoder layer (defaults to <tt>%w[gzip deflate]</tt>).
         | 
| @@ -124,10 +124,6 @@ module HTTPX | |
| 124 124 | 
             
                # :base_path :: path to prefix given relative paths with (ex: "/v2")
         | 
| 125 125 | 
             
                # :max_concurrent_requests :: max number of requests which can be set concurrently
         | 
| 126 126 | 
             
                # :max_requests :: max number of requests which can be made on socket before it reconnects.
         | 
| 127 | 
            -
                # :params :: hash or array of key-values which will be encoded and set in the query string of request uris.
         | 
| 128 | 
            -
                # :form :: hash of array of key-values which will be form-or-multipart-encoded in requests body payload.
         | 
| 129 | 
            -
                # :json :: hash of array of key-values which will be JSON-encoded in requests body payload.
         | 
| 130 | 
            -
                # :xml :: Nokogiri XML nodes which will be encoded in requests body payload.
         | 
| 131 127 | 
             
                #
         | 
| 132 128 | 
             
                # This list of options are enhanced with each loaded plugin, see the plugin docs for details.
         | 
| 133 129 | 
             
                def initialize(options = {})
         | 
| @@ -216,7 +212,7 @@ module HTTPX | |
| 216 212 | 
             
                end
         | 
| 217 213 |  | 
| 218 214 | 
             
                %i[
         | 
| 219 | 
            -
                   | 
| 215 | 
            +
                  ssl http2_settings
         | 
| 220 216 | 
             
                  request_class response_class headers_class request_body_class
         | 
| 221 217 | 
             
                  response_body_class connection_class options_class
         | 
| 222 218 | 
             
                  io fallback_protocol debug debug_level resolver_class resolver_options
         | 
| @@ -228,7 +224,7 @@ module HTTPX | |
| 228 224 | 
             
                  OUT
         | 
| 229 225 | 
             
                end
         | 
| 230 226 |  | 
| 231 | 
            -
                REQUEST_BODY_IVARS = %i[@headers | 
| 227 | 
            +
                REQUEST_BODY_IVARS = %i[@headers].freeze
         | 
| 232 228 |  | 
| 233 229 | 
             
                def ==(other)
         | 
| 234 230 | 
             
                  super || options_equals?(other)
         | 
| @@ -40,6 +40,12 @@ module HTTPX | |
| 40 40 | 
             
                      end
         | 
| 41 41 | 
             
                    end
         | 
| 42 42 |  | 
| 43 | 
            +
                    def build_request(*)
         | 
| 44 | 
            +
                      request = super
         | 
| 45 | 
            +
                      request.headers.set_cookie(request.options.cookies[request.uri])
         | 
| 46 | 
            +
                      request
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
             | 
| 43 49 | 
             
                    private
         | 
| 44 50 |  | 
| 45 51 | 
             
                    def on_response(_request, response)
         | 
| @@ -52,12 +58,6 @@ module HTTPX | |
| 52 58 |  | 
| 53 59 | 
             
                      super
         | 
| 54 60 | 
             
                    end
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                    def build_request(*, _)
         | 
| 57 | 
            -
                      request = super
         | 
| 58 | 
            -
                      request.headers.set_cookie(request.options.cookies[request.uri])
         | 
| 59 | 
            -
                      request
         | 
| 60 | 
            -
                    end
         | 
| 61 61 | 
             
                  end
         | 
| 62 62 |  | 
| 63 63 | 
             
                  module HeadersMethods
         | 
| @@ -71,40 +71,40 @@ module HTTPX | |
| 71 71 | 
             
                      # build redirect request
         | 
| 72 72 | 
             
                      request_body = redirect_request.body
         | 
| 73 73 | 
             
                      redirect_method = "GET"
         | 
| 74 | 
            +
                      redirect_params = {}
         | 
| 74 75 |  | 
| 75 76 | 
             
                      if response.status == 305 && options.respond_to?(:proxy)
         | 
| 76 77 | 
             
                        request_body.rewind
         | 
| 77 78 | 
             
                        # The requested resource MUST be accessed through the proxy given by
         | 
| 78 79 | 
             
                        # the Location field. The Location field gives the URI of the proxy.
         | 
| 79 | 
            -
                         | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 80 | 
            +
                        redirect_options = options.merge(headers: redirect_request.headers,
         | 
| 81 | 
            +
                                                         proxy: { uri: redirect_uri },
         | 
| 82 | 
            +
                                                         max_redirects: max_redirects - 1)
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                        redirect_params[:body] = request_body
         | 
| 83 85 | 
             
                        redirect_uri = redirect_request.uri
         | 
| 84 | 
            -
                        options =  | 
| 86 | 
            +
                        options = redirect_options
         | 
| 85 87 | 
             
                      else
         | 
| 86 88 | 
             
                        redirect_headers = redirect_request_headers(redirect_request.uri, redirect_uri, request.headers, options)
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                         | 
| 89 | 
            +
                        redirect_opts = Hash[options]
         | 
| 90 | 
            +
                        redirect_params[:max_redirects] = max_redirects - 1
         | 
| 89 91 |  | 
| 90 92 | 
             
                        unless request_body.empty?
         | 
| 91 93 | 
             
                          if response.status == 307
         | 
| 92 94 | 
             
                            # The method and the body of the original request are reused to perform the redirected request.
         | 
| 93 95 | 
             
                            redirect_method = redirect_request.verb
         | 
| 94 96 | 
             
                            request_body.rewind
         | 
| 95 | 
            -
                             | 
| 97 | 
            +
                            redirect_params[:body] = request_body
         | 
| 96 98 | 
             
                          else
         | 
| 97 99 | 
             
                            # redirects are **ALWAYS** GET, so remove body-related headers
         | 
| 98 100 | 
             
                            REQUEST_BODY_HEADERS.each do |h|
         | 
| 99 101 | 
             
                              redirect_headers.delete(h)
         | 
| 100 102 | 
             
                            end
         | 
| 101 | 
            -
                             | 
| 103 | 
            +
                            redirect_params[:body] = nil
         | 
| 102 104 | 
             
                          end
         | 
| 103 105 | 
             
                        end
         | 
| 104 106 |  | 
| 105 | 
            -
                         | 
| 106 | 
            -
             | 
| 107 | 
            -
                        retry_options = options.class.new(retry_opts)
         | 
| 107 | 
            +
                        options = options.class.new(redirect_opts.merge(headers: redirect_headers.to_h))
         | 
| 108 108 | 
             
                      end
         | 
| 109 109 |  | 
| 110 110 | 
             
                      redirect_uri = Utils.to_uri(redirect_uri)
         | 
| @@ -114,26 +114,26 @@ module HTTPX | |
| 114 114 | 
             
                         redirect_uri.scheme == "http"
         | 
| 115 115 | 
             
                        error = InsecureRedirectError.new(redirect_uri.to_s)
         | 
| 116 116 | 
             
                        error.set_backtrace(caller)
         | 
| 117 | 
            -
                        return ErrorResponse.new(request, error | 
| 117 | 
            +
                        return ErrorResponse.new(request, error)
         | 
| 118 118 | 
             
                      end
         | 
| 119 119 |  | 
| 120 | 
            -
                      retry_request = build_request(redirect_method, redirect_uri,  | 
| 120 | 
            +
                      retry_request = build_request(redirect_method, redirect_uri, redirect_params, options)
         | 
| 121 121 |  | 
| 122 122 | 
             
                      request.redirect_request = retry_request
         | 
| 123 123 |  | 
| 124 | 
            -
                       | 
| 124 | 
            +
                      redirect_after = response.headers["retry-after"]
         | 
| 125 125 |  | 
| 126 | 
            -
                      if  | 
| 126 | 
            +
                      if redirect_after
         | 
| 127 127 | 
             
                        # Servers send the "Retry-After" header field to indicate how long the
         | 
| 128 128 | 
             
                        # user agent ought to wait before making a follow-up request.
         | 
| 129 129 | 
             
                        # When sent with any 3xx (Redirection) response, Retry-After indicates
         | 
| 130 130 | 
             
                        # the minimum time that the user agent is asked to wait before issuing
         | 
| 131 131 | 
             
                        # the redirected request.
         | 
| 132 132 | 
             
                        #
         | 
| 133 | 
            -
                         | 
| 133 | 
            +
                        redirect_after = Utils.parse_retry_after(redirect_after)
         | 
| 134 134 |  | 
| 135 | 
            -
                        log { "redirecting after #{ | 
| 136 | 
            -
                        pool.after( | 
| 135 | 
            +
                        log { "redirecting after #{redirect_after} secs..." }
         | 
| 136 | 
            +
                        pool.after(redirect_after) do
         | 
| 137 137 | 
             
                          send_request(retry_request, connections, options)
         | 
| 138 138 | 
             
                        end
         | 
| 139 139 | 
             
                      else
         | 
| @@ -149,10 +149,9 @@ module HTTPX | |
| 149 149 |  | 
| 150 150 | 
             
                      return headers unless headers.key?("authorization")
         | 
| 151 151 |  | 
| 152 | 
            -
                       | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
                      end
         | 
| 152 | 
            +
                      return headers if original_uri.origin == redirect_uri.origin
         | 
| 153 | 
            +
             | 
| 154 | 
            +
                      headers.delete("authorization")
         | 
| 156 155 |  | 
| 157 156 | 
             
                      headers
         | 
| 158 157 | 
             
                    end
         | 
    
        data/lib/httpx/plugins/grpc.rb
    CHANGED
    
    | @@ -110,10 +110,10 @@ module HTTPX | |
| 110 110 | 
             
                  end
         | 
| 111 111 |  | 
| 112 112 | 
             
                  module RequestBodyMethods
         | 
| 113 | 
            -
                    def initialize( | 
| 113 | 
            +
                    def initialize(*, **)
         | 
| 114 114 | 
             
                      super
         | 
| 115 115 |  | 
| 116 | 
            -
                      if (compression = headers["grpc-encoding"])
         | 
| 116 | 
            +
                      if (compression = @headers["grpc-encoding"])
         | 
| 117 117 | 
             
                        deflater_body = self.class.initialize_deflater_body(@body, compression)
         | 
| 118 118 | 
             
                        @body = Transcoder::GRPCEncoding.encode(deflater_body || @body, compressed: !deflater_body.nil?)
         | 
| 119 119 | 
             
                      else
         | 
    
        data/lib/httpx/plugins/h2c.rb
    CHANGED
    
    | @@ -39,7 +39,7 @@ module HTTPX | |
| 39 39 | 
             
                      upgrade_request.headers.add("connection", "upgrade")
         | 
| 40 40 | 
             
                      upgrade_request.headers.add("connection", "http2-settings")
         | 
| 41 41 | 
             
                      upgrade_request.headers["upgrade"] = "h2c"
         | 
| 42 | 
            -
                      upgrade_request.headers["http2-settings"] =  | 
| 42 | 
            +
                      upgrade_request.headers["http2-settings"] = ::HTTP2::Client.settings_header(upgrade_request.options.http2_settings)
         | 
| 43 43 |  | 
| 44 44 | 
             
                      super(upgrade_request, *remainder)
         | 
| 45 45 | 
             
                    end
         | 
    
        data/lib/httpx/plugins/oauth.rb
    CHANGED
    
    | @@ -155,7 +155,7 @@ module HTTPX | |
| 155 155 | 
             
                      with(oauth_session: oauth_session.merge(access_token: access_token, refresh_token: refresh_token))
         | 
| 156 156 | 
             
                    end
         | 
| 157 157 |  | 
| 158 | 
            -
                    def build_request( | 
| 158 | 
            +
                    def build_request(*)
         | 
| 159 159 | 
             
                      request = super
         | 
| 160 160 |  | 
| 161 161 | 
             
                      return request if request.headers.key?("authorization")
         | 
| @@ -100,7 +100,7 @@ module HTTPX | |
| 100 100 |  | 
| 101 101 | 
             
                        error = ServerSideRequestForgeryError.new("#{request.uri} URI scheme not allowed")
         | 
| 102 102 | 
             
                        error.set_backtrace(caller)
         | 
| 103 | 
            -
                        response = ErrorResponse.new(request, error | 
| 103 | 
            +
                        response = ErrorResponse.new(request, error)
         | 
| 104 104 | 
             
                        request.emit(:response, response)
         | 
| 105 105 | 
             
                        response
         | 
| 106 106 | 
             
                      end
         | 
    
        data/lib/httpx/request/body.rb
    CHANGED
    
    | @@ -4,30 +4,53 @@ module HTTPX | |
| 4 4 | 
             
              # Implementation of the HTTP Request body as a delegator which iterates (responds to +each+) payload chunks.
         | 
| 5 5 | 
             
              class Request::Body < SimpleDelegator
         | 
| 6 6 | 
             
                class << self
         | 
| 7 | 
            -
                  def new(_, options)
         | 
| 8 | 
            -
                     | 
| 7 | 
            +
                  def new(_, options, body: nil, **params)
         | 
| 8 | 
            +
                    if body.is_a?(self)
         | 
| 9 | 
            +
                      # request derives its options from body
         | 
| 10 | 
            +
                      body.options = options.merge(params)
         | 
| 11 | 
            +
                      return body
         | 
| 12 | 
            +
                    end
         | 
| 9 13 |  | 
| 10 14 | 
             
                    super
         | 
| 11 15 | 
             
                  end
         | 
| 12 16 | 
             
                end
         | 
| 13 17 |  | 
| 14 | 
            -
                 | 
| 15 | 
            -
                def initialize(headers, options)
         | 
| 16 | 
            -
                  @headers = headers
         | 
| 18 | 
            +
                attr_accessor :options
         | 
| 17 19 |  | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
                # inits the instance with the request +headers+, +options+ and +params+, which contain the payload definition.
         | 
| 21 | 
            +
                # it wraps the given body with the appropriate encoder on initialization.
         | 
| 22 | 
            +
                #
         | 
| 23 | 
            +
                #   ..., json: { foo: "bar" }) #=> json encoder
         | 
| 24 | 
            +
                #   ..., form: { foo: "bar" }) #=> form urlencoded encoder
         | 
| 25 | 
            +
                #   ..., form: { foo: Pathname.open("path/to/file") }) #=> multipart urlencoded encoder
         | 
| 26 | 
            +
                #   ..., form: { foo: File.open("path/to/file") }) #=> multipart urlencoded encoder
         | 
| 27 | 
            +
                #   ..., form: { body: "bla") }) #=> raw data encoder
         | 
| 28 | 
            +
                def initialize(headers, options, body: nil, form: nil, json: nil, xml: nil, **params)
         | 
| 29 | 
            +
                  @headers = headers
         | 
| 30 | 
            +
                  @options = options.merge(params)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  @body = if body
         | 
| 33 | 
            +
                    Transcoder::Body.encode(body)
         | 
| 34 | 
            +
                  elsif form
         | 
| 35 | 
            +
                    Transcoder::Form.encode(form)
         | 
| 36 | 
            +
                  elsif json
         | 
| 37 | 
            +
                    Transcoder::JSON.encode(json)
         | 
| 38 | 
            +
                  elsif xml
         | 
| 39 | 
            +
                    Transcoder::Xml.encode(xml)
         | 
| 23 40 | 
             
                  end
         | 
| 24 41 |  | 
| 25 | 
            -
                   | 
| 42 | 
            +
                  if @body
         | 
| 43 | 
            +
                    if @options.compress_request_body && @headers.key?("content-encoding")
         | 
| 26 44 |  | 
| 27 | 
            -
             | 
| 45 | 
            +
                      @headers.get("content-encoding").each do |encoding|
         | 
| 46 | 
            +
                        @body = self.class.initialize_deflater_body(@body, encoding)
         | 
| 47 | 
            +
                      end
         | 
| 48 | 
            +
                    end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                    @headers["content-type"] ||= @body.content_type
         | 
| 51 | 
            +
                    @headers["content-length"] = @body.bytesize unless unbounded_body?
         | 
| 52 | 
            +
                  end
         | 
| 28 53 |  | 
| 29 | 
            -
                  @headers["content-type"] ||= @body.content_type
         | 
| 30 | 
            -
                  @headers["content-length"] = @body.bytesize unless unbounded_body?
         | 
| 31 54 | 
             
                  super(@body)
         | 
| 32 55 | 
             
                end
         | 
| 33 56 |  | 
| @@ -99,33 +122,6 @@ module HTTPX | |
| 99 122 | 
             
                end
         | 
| 100 123 | 
             
                # :nocov:
         | 
| 101 124 |  | 
| 102 | 
            -
                private
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                # wraps the given body with the appropriate encoder.
         | 
| 105 | 
            -
                #
         | 
| 106 | 
            -
                #   ..., json: { foo: "bar" }) #=> json encoder
         | 
| 107 | 
            -
                #   ..., form: { foo: "bar" }) #=> form urlencoded encoder
         | 
| 108 | 
            -
                #   ..., form: { foo: Pathname.open("path/to/file") }) #=> multipart urlencoded encoder
         | 
| 109 | 
            -
                #   ..., form: { foo: File.open("path/to/file") }) #=> multipart urlencoded encoder
         | 
| 110 | 
            -
                #   ..., form: { body: "bla") }) #=> raw data encoder
         | 
| 111 | 
            -
                def initialize_body(options)
         | 
| 112 | 
            -
                  @body = if options.body
         | 
| 113 | 
            -
                    Transcoder::Body.encode(options.body)
         | 
| 114 | 
            -
                  elsif options.form
         | 
| 115 | 
            -
                    Transcoder::Form.encode(options.form)
         | 
| 116 | 
            -
                  elsif options.json
         | 
| 117 | 
            -
                    Transcoder::JSON.encode(options.json)
         | 
| 118 | 
            -
                  elsif options.xml
         | 
| 119 | 
            -
                    Transcoder::Xml.encode(options.xml)
         | 
| 120 | 
            -
                  end
         | 
| 121 | 
            -
             | 
| 122 | 
            -
                  return unless @body && options.compress_request_body && @headers.key?("content-encoding")
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                  @headers.get("content-encoding").each do |encoding|
         | 
| 125 | 
            -
                    @body = self.class.initialize_deflater_body(@body, encoding)
         | 
| 126 | 
            -
                  end
         | 
| 127 | 
            -
                end
         | 
| 128 | 
            -
             | 
| 129 125 | 
             
                class << self
         | 
| 130 126 | 
             
                  # returns the +body+ wrapped with the correct deflater accordinng to the given +encodisng+.
         | 
| 131 127 | 
             
                  def initialize_deflater_body(body, encoding)
         | 
    
        data/lib/httpx/request.rb
    CHANGED
    
    | @@ -46,12 +46,43 @@ module HTTPX | |
| 46 46 | 
             
                # will be +true+ when request body has been completely flushed.
         | 
| 47 47 | 
             
                def_delegator :@body, :empty?
         | 
| 48 48 |  | 
| 49 | 
            -
                # initializes the instance with the given +verb | 
| 50 | 
            -
                #  | 
| 51 | 
            -
                 | 
| 49 | 
            +
                # initializes the instance with the given +verb+ (an upppercase String, ex. 'GEt'),
         | 
| 50 | 
            +
                # an absolute or relative +uri+ (either as String or URI::HTTP object), the
         | 
| 51 | 
            +
                # request +options+ (instance of HTTPX::Options) and an optional Hash of +params+.
         | 
| 52 | 
            +
                #
         | 
| 53 | 
            +
                # Besides any of the options documented in HTTPX::Options (which would override or merge with what
         | 
| 54 | 
            +
                # +options+ sets), it accepts also the following:
         | 
| 55 | 
            +
                #
         | 
| 56 | 
            +
                # :params :: hash or array of key-values which will be encoded and set in the query string of request uris.
         | 
| 57 | 
            +
                # :body :: to be encoded in the request body payload. can be a String, an IO object (i.e. a File), or an Enumerable.
         | 
| 58 | 
            +
                # :form :: hash of array of key-values which will be form-urlencoded- or multipart-encoded in requests body payload.
         | 
| 59 | 
            +
                # :json :: hash of array of key-values which will be JSON-encoded in requests body payload.
         | 
| 60 | 
            +
                # :xml :: Nokogiri XML nodes which will be encoded in requests body payload.
         | 
| 61 | 
            +
                #
         | 
| 62 | 
            +
                # :body, :form, :json and :xml are all mutually exclusive, i.e. only one of them gets picked up.
         | 
| 63 | 
            +
                def initialize(verb, uri, options, params = EMPTY_HASH)
         | 
| 52 64 | 
             
                  @verb    = verb.to_s.upcase
         | 
| 53 | 
            -
                  @options = Options.new(options)
         | 
| 54 65 | 
             
                  @uri     = Utils.to_uri(uri)
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  @headers = options.headers.dup
         | 
| 68 | 
            +
                  merge_headers(params.delete(:headers)) if params.key?(:headers)
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  @headers["user-agent"] ||= USER_AGENT
         | 
| 71 | 
            +
                  @headers["accept"]     ||= "*/*"
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  # forego compression in the Range request case
         | 
| 74 | 
            +
                  if @headers.key?("range")
         | 
| 75 | 
            +
                    @headers.delete("accept-encoding")
         | 
| 76 | 
            +
                  else
         | 
| 77 | 
            +
                    @headers["accept-encoding"] ||= options.supported_compression_formats
         | 
| 78 | 
            +
                  end
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                  @query_params = params.delete(:params) if params.key?(:params)
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  @body = options.request_body_class.new(@headers, options, **params)
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                  @options = @body.options
         | 
| 85 | 
            +
             | 
| 55 86 | 
             
                  if @uri.relative?
         | 
| 56 87 | 
             
                    origin = @options.origin
         | 
| 57 88 | 
             
                    raise(Error, "invalid URI: #{@uri}") unless origin
         | 
| @@ -61,11 +92,6 @@ module HTTPX | |
| 61 92 | 
             
                    @uri = origin.merge("#{base_path}#{@uri}")
         | 
| 62 93 | 
             
                  end
         | 
| 63 94 |  | 
| 64 | 
            -
                  @headers = @options.headers.dup
         | 
| 65 | 
            -
                  @headers["user-agent"] ||= USER_AGENT
         | 
| 66 | 
            -
                  @headers["accept"]     ||= "*/*"
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                  @body = @options.request_body_class.new(@headers, @options)
         | 
| 69 95 | 
             
                  @state = :idle
         | 
| 70 96 | 
             
                  @response = nil
         | 
| 71 97 | 
             
                  @peer_address = nil
         | 
| @@ -172,7 +198,7 @@ module HTTPX | |
| 172 198 | 
             
                  return @query if defined?(@query)
         | 
| 173 199 |  | 
| 174 200 | 
             
                  query = []
         | 
| 175 | 
            -
                  if (q = @ | 
| 201 | 
            +
                  if (q = @query_params)
         | 
| 176 202 | 
             
                    query << Transcoder::Form.encode(q)
         | 
| 177 203 | 
             
                  end
         | 
| 178 204 | 
             
                  query << @uri.query if @uri.query
         | 
    
        data/lib/httpx/resolver/https.rb
    CHANGED
    
    | @@ -219,7 +219,7 @@ module HTTPX | |
| 219 219 | 
             
                    uri.query = URI.encode_www_form(params)
         | 
| 220 220 | 
             
                    request = rklass.new("GET", uri, @options)
         | 
| 221 221 | 
             
                  else
         | 
| 222 | 
            -
                    request = rklass.new("POST", uri, @options | 
| 222 | 
            +
                    request = rklass.new("POST", uri, @options, body: [payload])
         | 
| 223 223 | 
             
                    request.headers["content-type"] = "application/dns-message"
         | 
| 224 224 | 
             
                  end
         | 
| 225 225 | 
             
                  request.headers["accept"] = "application/dns-message"
         | 
    
        data/lib/httpx/response.rb
    CHANGED
    
    | @@ -247,11 +247,11 @@ module HTTPX | |
| 247 247 | 
             
                # the IP address of the peer server.
         | 
| 248 248 | 
             
                def_delegator :@request, :peer_address
         | 
| 249 249 |  | 
| 250 | 
            -
                def initialize(request, error | 
| 250 | 
            +
                def initialize(request, error)
         | 
| 251 251 | 
             
                  @request = request
         | 
| 252 252 | 
             
                  @response = request.response if request.response.is_a?(Response)
         | 
| 253 253 | 
             
                  @error = error
         | 
| 254 | 
            -
                  @options =  | 
| 254 | 
            +
                  @options = request.options
         | 
| 255 255 | 
             
                  log_exception(@error)
         | 
| 256 256 | 
             
                end
         | 
| 257 257 |  | 
    
        data/lib/httpx/session.rb
    CHANGED
    
    | @@ -1,6 +1,8 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module HTTPX
         | 
| 4 | 
            +
              EMPTY_HASH = {}.freeze
         | 
| 5 | 
            +
             | 
| 4 6 | 
             
              # Class implementing the APIs being used publicly.
         | 
| 5 7 | 
             
              #
         | 
| 6 8 | 
             
              #   HTTPX.get(..) #=> delegating to an internal HTTPX::Session object.
         | 
| @@ -9,8 +11,6 @@ module HTTPX | |
| 9 11 | 
             
                include Loggable
         | 
| 10 12 | 
             
                include Chainable
         | 
| 11 13 |  | 
| 12 | 
            -
                EMPTY_HASH = {}.freeze
         | 
| 13 | 
            -
             | 
| 14 14 | 
             
                # initializes the session with a set of +options+, which will be shared by all
         | 
| 15 15 | 
             
                # requests sent from it.
         | 
| 16 16 | 
             
                #
         | 
| @@ -65,10 +65,10 @@ module HTTPX | |
| 65 65 | 
             
                #  resp1, resp2 = session.request(["POST", "https://server.org/a", form: { "foo" => "bar" }], ["GET", "https://server.org/b"])
         | 
| 66 66 | 
             
                #  resp1, resp2 = session.request("GET", ["https://server.org/a", "https://server.org/b"], headers: { "x-api-token" => "TOKEN" })
         | 
| 67 67 | 
             
                #
         | 
| 68 | 
            -
                def request(*args, ** | 
| 68 | 
            +
                def request(*args, **params)
         | 
| 69 69 | 
             
                  raise ArgumentError, "must perform at least one request" if args.empty?
         | 
| 70 70 |  | 
| 71 | 
            -
                  requests = args.first.is_a?(Request) ? args : build_requests(*args,  | 
| 71 | 
            +
                  requests = args.first.is_a?(Request) ? args : build_requests(*args, params)
         | 
| 72 72 | 
             
                  responses = send_requests(*requests)
         | 
| 73 73 | 
             
                  return responses.first if responses.size == 1
         | 
| 74 74 |  | 
| @@ -81,10 +81,9 @@ module HTTPX | |
| 81 81 | 
             
                #
         | 
| 82 82 | 
             
                #   req = session.build_request("GET", "https://server.com")
         | 
| 83 83 | 
             
                #   resp = session.request(req)
         | 
| 84 | 
            -
                def build_request(verb, uri, options =  | 
| 85 | 
            -
                  rklass =  | 
| 86 | 
            -
                   | 
| 87 | 
            -
                  request = rklass.new(verb, uri, options)
         | 
| 84 | 
            +
                def build_request(verb, uri, params = EMPTY_HASH, options = @options)
         | 
| 85 | 
            +
                  rklass = options.request_class
         | 
| 86 | 
            +
                  request = rklass.new(verb, uri, options, params)
         | 
| 88 87 | 
             
                  request.persistent = @persistent
         | 
| 89 88 | 
             
                  set_request_callbacks(request)
         | 
| 90 89 | 
             
                  request
         | 
| @@ -133,7 +132,7 @@ module HTTPX | |
| 133 132 | 
             
                  end
         | 
| 134 133 | 
             
                  return unless error.is_a?(Error)
         | 
| 135 134 |  | 
| 136 | 
            -
                  request.emit(:response, ErrorResponse.new(request, error | 
| 135 | 
            +
                  request.emit(:response, ErrorResponse.new(request, error))
         | 
| 137 136 | 
             
                end
         | 
| 138 137 |  | 
| 139 138 | 
             
                # sets the callbacks on the +connection+ required to process certain specific
         | 
| @@ -192,22 +191,26 @@ module HTTPX | |
| 192 191 | 
             
                end
         | 
| 193 192 |  | 
| 194 193 | 
             
                # returns a set of HTTPX::Request objects built from the given +args+ and +options+.
         | 
| 195 | 
            -
                def build_requests(*args,  | 
| 196 | 
            -
                  request_options = @options.merge(options)
         | 
| 197 | 
            -
             | 
| 194 | 
            +
                def build_requests(*args, params)
         | 
| 198 195 | 
             
                  requests = if args.size == 1
         | 
| 199 196 | 
             
                    reqs = args.first
         | 
| 200 | 
            -
                     | 
| 201 | 
            -
             | 
| 197 | 
            +
                    # TODO: find a way to make requests share same options object
         | 
| 198 | 
            +
                    reqs.map do |verb, uri, ps = EMPTY_HASH|
         | 
| 199 | 
            +
                      request_params = params
         | 
| 200 | 
            +
                      request_params = request_params.merge(ps) unless ps.empty?
         | 
| 201 | 
            +
                      build_request(verb, uri, request_params)
         | 
| 202 202 | 
             
                    end
         | 
| 203 203 | 
             
                  else
         | 
| 204 204 | 
             
                    verb, uris = args
         | 
| 205 205 | 
             
                    if uris.respond_to?(:each)
         | 
| 206 | 
            -
                       | 
| 207 | 
            -
             | 
| 206 | 
            +
                      # TODO: find a way to make requests share same options object
         | 
| 207 | 
            +
                      uris.enum_for(:each).map do |uri, ps = EMPTY_HASH|
         | 
| 208 | 
            +
                        request_params = params
         | 
| 209 | 
            +
                        request_params = request_params.merge(ps) unless ps.empty?
         | 
| 210 | 
            +
                        build_request(verb, uri, request_params)
         | 
| 208 211 | 
             
                      end
         | 
| 209 212 | 
             
                    else
         | 
| 210 | 
            -
                      [build_request(verb, uris,  | 
| 213 | 
            +
                      [build_request(verb, uris, params)]
         | 
| 211 214 | 
             
                    end
         | 
| 212 215 | 
             
                  end
         | 
| 213 216 | 
             
                  raise ArgumentError, "wrong number of URIs (given 0, expect 1..+1)" if requests.empty?
         | 
    
        data/lib/httpx/timers.rb
    CHANGED
    
    | @@ -43,7 +43,7 @@ module HTTPX | |
| 43 43 |  | 
| 44 44 | 
             
                  elapsed_time = Utils.elapsed_time(@next_interval_at)
         | 
| 45 45 |  | 
| 46 | 
            -
                  @intervals. | 
| 46 | 
            +
                  @intervals = @intervals.drop_while { |interval| interval.elapse(elapsed_time) <= 0 }
         | 
| 47 47 |  | 
| 48 48 | 
             
                  @next_interval_at = nil if @intervals.empty?
         | 
| 49 49 | 
             
                end
         | 
    
        data/lib/httpx/version.rb
    CHANGED
    
    
    
        data/sig/chainable.rbs
    CHANGED
    
    | @@ -3,8 +3,8 @@ module HTTPX | |
| 3 3 | 
             
                def request: (*Request, **untyped) -> Array[response]
         | 
| 4 4 | 
             
                           | (Request, **untyped) -> response
         | 
| 5 5 | 
             
                           | (verb, uri | [uri], **untyped) -> response
         | 
| 6 | 
            -
                           | (Array[[verb, uri] | [verb, uri,  | 
| 7 | 
            -
                           | (verb, _Each[uri | [uri,  | 
| 6 | 
            +
                           | (Array[[verb, uri] | [verb, uri, request_params]], **untyped) -> Array[response]
         | 
| 7 | 
            +
                           | (verb, _Each[uri | [uri, request_params]], **untyped) -> Array[response]
         | 
| 8 8 |  | 
| 9 9 | 
             
                def accept: (String) -> Session
         | 
| 10 10 | 
             
                def wrap: () { (Session) -> void } -> void
         | 
    
        data/sig/connection/http1.rbs
    CHANGED
    
    
    
        data/sig/connection/http2.rbs
    CHANGED
    
    | @@ -5,7 +5,7 @@ module HTTPX | |
| 5 5 |  | 
| 6 6 | 
             
                MAX_CONCURRENT_REQUESTS: Integer
         | 
| 7 7 |  | 
| 8 | 
            -
                attr_reader streams: Hash[Request,  | 
| 8 | 
            +
                attr_reader streams: Hash[Request, ::HTTP2::Stream]
         | 
| 9 9 | 
             
                attr_reader pending: Array[Request]
         | 
| 10 10 |  | 
| 11 11 | 
             
                @options: Options
         | 
| @@ -42,35 +42,35 @@ module HTTPX | |
| 42 42 |  | 
| 43 43 | 
             
                private
         | 
| 44 44 |  | 
| 45 | 
            -
                def initialize: (Buffer, options) -> untyped
         | 
| 45 | 
            +
                def initialize: (Buffer buffer, Options options) -> untyped
         | 
| 46 46 |  | 
| 47 47 | 
             
                def send_pending: () -> void
         | 
| 48 48 |  | 
| 49 49 | 
             
                def set_protocol_headers: (Request) -> _Each[[String, String]]
         | 
| 50 50 |  | 
| 51 | 
            -
                def handle: (Request request,  | 
| 51 | 
            +
                def handle: (Request request, ::HTTP2::Stream stream) -> void
         | 
| 52 52 |  | 
| 53 53 | 
             
                def init_connection: () -> void
         | 
| 54 54 |  | 
| 55 | 
            -
                def handle_stream: ( | 
| 55 | 
            +
                def handle_stream: (::HTTP2::Stream stream, Request request) -> void
         | 
| 56 56 |  | 
| 57 57 | 
             
                def join_headline: (Request request) -> String
         | 
| 58 58 |  | 
| 59 | 
            -
                def join_headers: ( | 
| 59 | 
            +
                def join_headers: (::HTTP2::Stream stream, Request request) -> void
         | 
| 60 60 |  | 
| 61 | 
            -
                def join_trailers: ( | 
| 61 | 
            +
                def join_trailers: (::HTTP2::Stream stream, Request request) -> void
         | 
| 62 62 |  | 
| 63 | 
            -
                def join_body: ( | 
| 63 | 
            +
                def join_body: (::HTTP2::Stream stream, Request request) -> void
         | 
| 64 64 |  | 
| 65 | 
            -
                def on_stream_headers: ( | 
| 65 | 
            +
                def on_stream_headers: (::HTTP2::Stream stream, Request request, Array[[String, String]] headers) -> void
         | 
| 66 66 |  | 
| 67 | 
            -
                def on_stream_trailers: ( | 
| 67 | 
            +
                def on_stream_trailers: (::HTTP2::Stream stream, Response response, Array[[String, String]] headers) -> void
         | 
| 68 68 |  | 
| 69 | 
            -
                def on_stream_data: ( | 
| 69 | 
            +
                def on_stream_data: (::HTTP2::Stream stream, Request request, String data) -> void
         | 
| 70 70 |  | 
| 71 | 
            -
                def on_stream_refuse: ( | 
| 71 | 
            +
                def on_stream_refuse: (::HTTP2::Stream stream, Request request, StandardError error) -> void
         | 
| 72 72 |  | 
| 73 | 
            -
                def on_stream_close: ( | 
| 73 | 
            +
                def on_stream_close: (::HTTP2::Stream stream, Request request, (Symbol | StandardError)? error) -> void
         | 
| 74 74 |  | 
| 75 75 | 
             
                def on_frame: (string bytes) -> void
         | 
| 76 76 |  | 
| @@ -78,13 +78,13 @@ module HTTPX | |
| 78 78 |  | 
| 79 79 | 
             
                def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
         | 
| 80 80 |  | 
| 81 | 
            -
                def on_frame_sent: ( | 
| 81 | 
            +
                def on_frame_sent: (::HTTP2::frame) -> void
         | 
| 82 82 |  | 
| 83 | 
            -
                def on_frame_received: ( | 
| 83 | 
            +
                def on_frame_received: (::HTTP2::frame) -> void
         | 
| 84 84 |  | 
| 85 | 
            -
                def on_altsvc: (String origin,  | 
| 85 | 
            +
                def on_altsvc: (String origin, ::HTTP2::frame) -> void
         | 
| 86 86 |  | 
| 87 | 
            -
                def on_promise: ( | 
| 87 | 
            +
                def on_promise: (::HTTP2::Stream) -> void
         | 
| 88 88 |  | 
| 89 89 | 
             
                def on_origin: (String) -> void
         | 
| 90 90 |  | 
    
        data/sig/connection.rbs
    CHANGED
    
    | @@ -93,9 +93,9 @@ module HTTPX | |
| 93 93 |  | 
| 94 94 | 
             
                private
         | 
| 95 95 |  | 
| 96 | 
            -
                def initialize: (http_uri uri, options) -> void
         | 
| 96 | 
            +
                def initialize: (http_uri uri, Options options) -> void
         | 
| 97 97 |  | 
| 98 | 
            -
                def initialize_type: (http_uri uri, Options) -> io_type
         | 
| 98 | 
            +
                def initialize_type: (http_uri uri, Options options) -> io_type
         | 
| 99 99 |  | 
| 100 100 | 
             
                def connect: () -> void
         | 
| 101 101 |  | 
    
        data/sig/httpx.rbs
    CHANGED
    
    | @@ -9,9 +9,9 @@ module HTTPX | |
| 9 9 | 
             
              type uri = http_uri | string
         | 
| 10 10 | 
             
              type generic_uri = String | URI::Generic
         | 
| 11 11 |  | 
| 12 | 
            -
              type verb =  | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 12 | 
            +
              type verb = String
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              type request_params = Hash[Symbol, untyped]
         | 
| 15 15 |  | 
| 16 16 | 
             
              type ip_family = Integer #Socket::AF_INET6 | Socket::AF_INET
         | 
| 17 17 |  | 
    
        data/sig/io/tcp.rbs
    CHANGED
    
    | @@ -15,7 +15,7 @@ module HTTPX | |
| 15 15 | 
             
                alias host ip
         | 
| 16 16 |  | 
| 17 17 | 
             
                # TODO: lift when https://github.com/ruby/rbs/issues/1497 fixed
         | 
| 18 | 
            -
                def initialize: (URI::Generic origin, Array[ipaddr]? addresses,  | 
| 18 | 
            +
                def initialize: (URI::Generic origin, Array[ipaddr]? addresses, Options options) ?{ (instance) -> void } -> void
         | 
| 19 19 |  | 
| 20 20 | 
             
                def add_addresses: (Array[ipaddr] addrs) -> void
         | 
| 21 21 |  | 
    
        data/sig/io/unix.rbs
    CHANGED
    
    
    
        data/sig/options.rbs
    CHANGED
    
    | @@ -63,19 +63,7 @@ module HTTPX | |
| 63 63 | 
             
                # decompress_response_body
         | 
| 64 64 | 
             
                attr_reader decompress_response_body: bool
         | 
| 65 65 |  | 
| 66 | 
            -
                #  | 
| 67 | 
            -
                attr_reader params: Transcoder::urlencoded_input?
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                # form
         | 
| 70 | 
            -
                attr_reader form: Transcoder::urlencoded_input?
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                # json
         | 
| 73 | 
            -
                attr_reader json: _ToJson?
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                # body
         | 
| 76 | 
            -
                attr_reader body: bodyIO?
         | 
| 77 | 
            -
             | 
| 78 | 
            -
                # body
         | 
| 66 | 
            +
                # origin
         | 
| 79 67 | 
             
                attr_reader origin: URI::Generic?
         | 
| 80 68 |  | 
| 81 69 | 
             
                # base_path
         | 
| @@ -24,7 +24,7 @@ module HTTPX | |
| 24 24 | 
             
                  module InstanceMethods
         | 
| 25 25 | 
             
                    def max_redirects: (_ToI) -> instance
         | 
| 26 26 |  | 
| 27 | 
            -
                    def  | 
| 27 | 
            +
                    def handle_after_redirect_request: (http_uri original_uri, http_uri redirect_uri, Request request, Options & _FollowRedirectsOptions options) -> void
         | 
| 28 28 |  | 
| 29 29 | 
             
                    def __get_location_from_response: (Response) -> http_uri
         | 
| 30 30 | 
             
                  end
         | 
    
        data/sig/plugins/proxy/http.rbs
    CHANGED
    
    
| @@ -9,9 +9,9 @@ module HTTPX | |
| 9 9 | 
             
                  module InstanceMethods
         | 
| 10 10 | 
             
                    private
         | 
| 11 11 |  | 
| 12 | 
            -
                    def promise_headers: () -> Hash[ | 
| 13 | 
            -
                    def __on_promise_request: (Connection::HTTP2,  | 
| 14 | 
            -
                    def __on_promise_response: (Connection::HTTP2,  | 
| 12 | 
            +
                    def promise_headers: () -> Hash[::HTTP2::Stream, Request]
         | 
| 13 | 
            +
                    def __on_promise_request: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
         | 
| 14 | 
            +
                    def __on_promise_response: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 | 
             
                end
         | 
| 17 17 |  | 
    
        data/sig/request/body.rbs
    CHANGED
    
    | @@ -4,7 +4,7 @@ module HTTPX | |
| 4 4 | 
             
                @body: body_encoder?
         | 
| 5 5 | 
             
                @unbounded_body: bool
         | 
| 6 6 |  | 
| 7 | 
            -
                def initialize: (Headers headers, Options options) -> void
         | 
| 7 | 
            +
                def initialize: (Headers headers, Options options, ?body: bodyIO, ?form: Transcoder::urlencoded_input?, ?json: _ToJson?, **untyped) -> void
         | 
| 8 8 |  | 
| 9 9 | 
             
                def each: () { (String) -> void } -> void
         | 
| 10 10 | 
             
                        | () -> Enumerable[String]
         | 
| @@ -25,8 +25,6 @@ module HTTPX | |
| 25 25 |  | 
| 26 26 | 
             
                private
         | 
| 27 27 |  | 
| 28 | 
            -
                def initialize_body: (Options options) -> void
         | 
| 29 | 
            -
             | 
| 30 28 | 
             
                def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
         | 
| 31 29 | 
             
              end
         | 
| 32 30 |  | 
    
        data/sig/request.rbs
    CHANGED
    
    | @@ -19,12 +19,13 @@ module HTTPX | |
| 19 19 |  | 
| 20 20 | 
             
                attr_writer persistent: bool
         | 
| 21 21 |  | 
| 22 | 
            +
                @query_params: Hash[interned, untyped]?
         | 
| 22 23 | 
             
                @trailers: Headers?
         | 
| 23 24 | 
             
                @informational_status: Integer?
         | 
| 24 25 | 
             
                @query: String?
         | 
| 25 26 | 
             
                @drainer: Enumerator[String, void]?
         | 
| 26 27 |  | 
| 27 | 
            -
                def initialize: (Symbol | String, generic_uri, ? | 
| 28 | 
            +
                def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
         | 
| 28 29 |  | 
| 29 30 | 
             
                def interests: () -> (:r | :w)
         | 
| 30 31 |  | 
    
        data/sig/resolver/resolver.rbs
    CHANGED
    
    | @@ -26,7 +26,7 @@ module HTTPX | |
| 26 26 |  | 
| 27 27 | 
             
                  def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses, bool early_resolve) -> void
         | 
| 28 28 |  | 
| 29 | 
            -
                  def initialize: (ip_family? family,  | 
| 29 | 
            +
                  def initialize: (ip_family? family, Options options) -> void
         | 
| 30 30 |  | 
| 31 31 | 
             
                  def early_resolve: (Connection connection, ?hostname: String) -> void
         | 
| 32 32 |  | 
    
        data/sig/response.rbs
    CHANGED
    
    
    
        data/sig/session.rbs
    CHANGED
    
    | @@ -15,7 +15,7 @@ module HTTPX | |
| 15 15 |  | 
| 16 16 | 
             
                def close: (*untyped) -> void
         | 
| 17 17 |  | 
| 18 | 
            -
                def build_request: (verb, generic_uri, ?options) -> Request
         | 
| 18 | 
            +
                def build_request: (verb verb, generic_uri uri, ?request_params params, ?Options options) -> Request
         | 
| 19 19 |  | 
| 20 20 | 
             
                def initialize: (?options) { (self) -> void } -> void
         | 
| 21 21 | 
             
                              | (?options) -> void
         | 
| @@ -23,8 +23,11 @@ module HTTPX | |
| 23 23 | 
             
                private
         | 
| 24 24 |  | 
| 25 25 | 
             
                def pool: -> Pool
         | 
| 26 | 
            +
             | 
| 26 27 | 
             
                def on_response: (Request, response) -> void
         | 
| 28 | 
            +
             | 
| 27 29 | 
             
                def on_promise: (untyped, untyped) -> void
         | 
| 30 | 
            +
             | 
| 28 31 | 
             
                def fetch_response: (Request request, Array[Connection] connections, untyped options) -> response?
         | 
| 29 32 |  | 
| 30 33 | 
             
                def find_connection: (Request request, Array[Connection] connections, Options options) -> Connection
         | 
| @@ -37,11 +40,11 @@ module HTTPX | |
| 37 40 |  | 
| 38 41 | 
             
                def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> (Connection & AltSvc::ConnectionMixin)?
         | 
| 39 42 |  | 
| 40 | 
            -
                def build_requests: (verb, uri,  | 
| 41 | 
            -
                                  | (Array[[verb, uri,  | 
| 42 | 
            -
                                  | (Array[[verb, uri]],  | 
| 43 | 
            -
                                  | (verb, _Each[[uri,  | 
| 44 | 
            -
                                  | (verb, _Each[uri],  | 
| 43 | 
            +
                def build_requests: (verb, uri, request_params) -> Array[Request]
         | 
| 44 | 
            +
                                  | (Array[[verb, uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
         | 
| 45 | 
            +
                                  | (Array[[verb, uri]], request_params) -> Array[Request]
         | 
| 46 | 
            +
                                  | (verb, _Each[[uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
         | 
| 47 | 
            +
                                  | (verb, _Each[uri], request_params) -> Array[Request]
         | 
| 45 48 |  | 
| 46 49 | 
             
                def init_connection: (http_uri uri, Options options) -> Connection
         | 
| 47 50 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,29 +1,29 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: httpx
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Tiago Cardoso
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024- | 
| 11 | 
            +
            date: 2024-07-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name: http-2 | 
| 14 | 
            +
              name: http-2
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version: 1.0. | 
| 19 | 
            +
                    version: 1.0.0
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version: 1.0. | 
| 26 | 
            +
                    version: 1.0.0
         | 
| 27 27 | 
             
            description: A client library for making HTTP requests from Ruby.
         | 
| 28 28 | 
             
            email:
         | 
| 29 29 | 
             
            - cardoso_tiago@hotmail.com
         | 
| @@ -144,6 +144,7 @@ extra_rdoc_files: | |
| 144 144 | 
             
            - doc/release_notes/1_2_4.md
         | 
| 145 145 | 
             
            - doc/release_notes/1_2_5.md
         | 
| 146 146 | 
             
            - doc/release_notes/1_2_6.md
         | 
| 147 | 
            +
            - doc/release_notes/1_3_0.md
         | 
| 147 148 | 
             
            files:
         | 
| 148 149 | 
             
            - LICENSE.txt
         | 
| 149 150 | 
             
            - README.md
         | 
| @@ -259,6 +260,7 @@ files: | |
| 259 260 | 
             
            - doc/release_notes/1_2_4.md
         | 
| 260 261 | 
             
            - doc/release_notes/1_2_5.md
         | 
| 261 262 | 
             
            - doc/release_notes/1_2_6.md
         | 
| 263 | 
            +
            - doc/release_notes/1_3_0.md
         | 
| 262 264 | 
             
            - lib/httpx.rb
         | 
| 263 265 | 
             
            - lib/httpx/adapters/datadog.rb
         | 
| 264 266 | 
             
            - lib/httpx/adapters/faraday.rb
         |