Skip to content

Commit

Permalink
Headline shouldn't include host for https requests through proxy.
Browse files Browse the repository at this point in the history
  • Loading branch information
Connorhd authored and ixti committed Apr 11, 2016
1 parent 51cbf1b commit 2625436
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/http/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def connect_using_proxy(socket)

# Compute HTTP request header for direct or proxy request
def headline
request_uri = using_proxy? ? uri : uri.omit(:scheme, :authority)
request_uri = (using_proxy? && !uri.https?) ? uri : uri.omit(:scheme, :authority)
"#{verb.to_s.upcase} #{request_uri.omit :fragment} HTTP/#{version}"
end

Expand Down
6 changes: 6 additions & 0 deletions spec/lib/http/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@
context "with proxy" do
let(:proxy) { {:user => "user", :pass => "pass"} }
it { is_expected.to eq "GET http://example.com/foo?bar=baz HTTP/1.1" }

context "and HTTPS uri" do
let(:request_uri) { "https://example.com/foo?bar=baz" }

it { is_expected.to eq "GET /foo?bar=baz HTTP/1.1" }
end
end
end
end

0 comments on commit 2625436

Please sign in to comment.