Skip to content

Commit

Permalink
http/request: Only use absolute form in http < 2
Browse files Browse the repository at this point in the history
  • Loading branch information
daurnimator committed Mar 13, 2019
1 parent 8c83eca commit d0b56ee
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions http/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -451,17 +451,29 @@ function request_methods:go(timeout)
if request_headers:get(":method") == "CONNECT" then
error("cannot use HTTP Proxy with CONNECT method")
end
-- TODO: Check if :path already has authority?
local old_url = self:to_uri(false)
host = assert(proxy.host, "proxy is missing host")
port = proxy.port or http_util.scheme_to_port[proxy.scheme]
-- proxy requests get a uri that includes host as their path
if not cloned_headers then
request_headers = request_headers:clone()
cloned_headers = true -- luacheck: ignore 311
-- TODO: figure out what :path should be when using a http2 proxy
if version ~= 2 then
-- for now, just force 1.1
version = 1.1
-- RFC 7230 Section 5.3.2
-- When making a request to a proxy, other than a CONNECT or server-wide
-- OPTIONS request (as detailed below), a client MUST send the target
-- URI in absolute-form as the request-target.
-- TODO: Check if :path already has authority?
local old_url = self:to_uri(false)
if not cloned_headers then
request_headers = request_headers:clone()
cloned_headers = true
end
request_headers:upsert(":path", old_url)
end
request_headers:upsert(":path", old_url)
if proxy.userinfo then
if not cloned_headers then
request_headers = request_headers:clone()
cloned_headers = true -- luacheck: ignore 311
end
request_headers:upsert("proxy-authorization", "basic " .. basexx.to_base64(proxy.userinfo), true)
end
end
Expand Down

0 comments on commit d0b56ee

Please sign in to comment.