@@ -451,17 +451,29 @@ function request_methods:go(timeout)
451
451
if request_headers :get (" :method" ) == " CONNECT" then
452
452
error (" cannot use HTTP Proxy with CONNECT method" )
453
453
end
454
- -- TODO: Check if :path already has authority?
455
- local old_url = self :to_uri (false )
456
454
host = assert (proxy .host , " proxy is missing host" )
457
455
port = proxy .port or http_util .scheme_to_port [proxy .scheme ]
458
- -- proxy requests get a uri that includes host as their path
459
- if not cloned_headers then
460
- request_headers = request_headers :clone ()
461
- cloned_headers = true -- luacheck: ignore 311
456
+ -- TODO: figure out what :path should be when using a http2 proxy
457
+ if version ~= 2 then
458
+ -- for now, just force 1.1
459
+ version = 1.1
460
+ -- RFC 7230 Section 5.3.2
461
+ -- When making a request to a proxy, other than a CONNECT or server-wide
462
+ -- OPTIONS request (as detailed below), a client MUST send the target
463
+ -- URI in absolute-form as the request-target.
464
+ -- TODO: Check if :path already has authority?
465
+ local old_url = self :to_uri (false )
466
+ if not cloned_headers then
467
+ request_headers = request_headers :clone ()
468
+ cloned_headers = true
469
+ end
470
+ request_headers :upsert (" :path" , old_url )
462
471
end
463
- request_headers :upsert (" :path" , old_url )
464
472
if proxy .userinfo then
473
+ if not cloned_headers then
474
+ request_headers = request_headers :clone ()
475
+ cloned_headers = true -- luacheck: ignore 311
476
+ end
465
477
request_headers :upsert (" proxy-authorization" , " basic " .. basexx .to_base64 (proxy .userinfo ), true )
466
478
end
467
479
end
0 commit comments