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