summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-07-13 13:09:24 -0700
committerGitHub <noreply@github.com>2018-07-13 13:09:24 -0700
commit7f5b42a74f1043c038d4644823a7497ff45fd50d (patch)
tree06e039e8b2a71ce51a45499ab3aa2954be3f5d2e
parent9251118ba2fb6c6a3891d4ebf4422a5d7f0fe644 (diff)
parent24eefdbf89c332bde5853531fdd86f5f015d3dcd (diff)
downloadchef-7f5b42a74f1043c038d4644823a7497ff45fd50d.tar.gz
Merge pull request #7465 from chef/lcg/fix-dup-query-params
Fix duplicated query parameters to resolve Chef::HTTP::Simple regression
-rw-r--r--lib/chef/http/http_request.rb2
-rw-r--r--spec/unit/http/http_request_spec.rb8
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index 9ee519c8ac..c38ac08133 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -152,7 +152,7 @@ class Chef
end
def configure_http_request(request_body = nil)
- req_path = (path).to_s
+ req_path = path.to_s.dup
req_path << "?#{query}" if query
@http_request = case method.to_s.downcase
diff --git a/spec/unit/http/http_request_spec.rb b/spec/unit/http/http_request_spec.rb
index 29562de021..c500c3b99e 100644
--- a/spec/unit/http/http_request_spec.rb
+++ b/spec/unit/http/http_request_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Klaas Jan Wierenga (<k.j.wierenga@gmail.com>)
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,6 +52,12 @@ describe Chef::HTTP::HTTPRequest do
expect(request.headers["Host"]).to eql("yourhost.com:8888")
end
+ it "should not mutate the URI when it contains parameters" do
+ # buggy constructor code mutated strings owned by the URI parameter
+ uri = URI("http://dummy.com/foo?bar=baz")
+ request = Chef::HTTP::HTTPRequest.new(:GET, uri, "")
+ expect(uri).to eql(URI("http://dummy.com/foo?bar=baz"))
+ end
end
context "with HTTPS url scheme" do