Skip to content

Commit c9558cc

Browse files
committed
Replace query_values delegation with stdlib URI encoding
Remove query_values/query_values= delegations from HTTP::URI. Query parameter merging in Request::Builder now uses stdlib URI.decode_www_form/URI.encode_www_form instead of Addressable's query_values API.
1 parent b6ca645 commit c9558cc

5 files changed

Lines changed: 9 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8080
- `HTTP::URI#request_uri` is no longer delegated to `Addressable::URI`
8181
- `HTTP::URI#omit` is no longer delegated to `Addressable::URI` and now
8282
returns `HTTP::URI` instead of `Addressable::URI` (#491)
83+
- `HTTP::URI#query_values` and `HTTP::URI#query_values=` delegations to
84+
`Addressable::URI`. Query parameter merging now uses stdlib
85+
`URI.decode_www_form`/`URI.encode_www_form`
8386

8487
### Changed
8588

Steepfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ target :lib do
1313
library "socket"
1414
library "tempfile"
1515
library "timeout"
16+
library "uri"
1617
library "zlib"
1718
end

lib/http/request/builder.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
require "uri"
4+
35
require "http/form_data"
46
require "http/headers"
57
require "http/connection"
@@ -126,7 +128,8 @@ def resolve_against_base(uri)
126128
def merge_query_params!(uri)
127129
return unless @options.params && !@options.params.empty?
128130

129-
uri.query_values = uri.query_values(Array).to_a.concat(@options.params.to_a)
131+
existing = ::URI.decode_www_form(uri.query || "")
132+
uri.query = ::URI.encode_www_form(existing.concat(@options.params.to_a))
130133
end
131134

132135
# Creates request headers

lib/http/uri.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class InvalidError < HTTP::RequestError; end
1212

1313
def_delegators :@uri, :scheme, :normalized_scheme, :user, :password,
1414
:authority, :normalized_authority
15-
def_delegators :@uri, :path, :path=, :query, :query=, :query_values, :query_values=
15+
def_delegators :@uri, :path, :path=, :query, :query=
1616
def_delegators :@uri, :fragment, :normalized_fragment, :join, :normalize
1717

1818
# Host, either a domain name or IP address

sig/http.rbs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,6 @@ module HTTP
608608
def path=: (String) -> String
609609
def query: () -> String?
610610
def query=: (String?) -> String?
611-
def query_values: (?untyped notation) -> untyped
612-
def query_values=: (untyped) -> untyped
613611
def request_uri: () -> String
614612
def fragment: () -> String?
615613
def normalized_fragment: () -> String?

0 commit comments

Comments
 (0)