@@ -77,6 +77,7 @@ local function new_stream(connection)
77
77
78
78
req_method = nil ; -- string
79
79
peer_version = nil ; -- 1.0 or 1.1
80
+ use_absolute_target = nil ; -- tristate boolean
80
81
has_main_headers = false ;
81
82
headers_in_progress = nil ;
82
83
headers_fifo = new_fifo ();
@@ -648,8 +649,27 @@ function stream_methods:write_headers(headers, end_stream, timeout)
648
649
assert (not headers :has (" :path" ), " CONNECT requests should not have a path" )
649
650
else
650
651
-- RFC 7230 Section 5.4: A client MUST send a Host header field in all HTTP/1.1 request messages.
651
- assert (self .connection .version < 1.1 or headers :has (" :authority" ), " missing authority" )
652
+ local has_authority = headers :has (" :authority" )
653
+ assert (has_authority or self .connection .version < 1.1 , " missing authority" )
652
654
target = assert (headers :get (" :path" ), " missing path" )
655
+
656
+ if self .use_absolute_target ~= false then
657
+ -- RFC 7230 Section 5.3.2
658
+ -- When making a request to a proxy, other than a CONNECT or server-wide
659
+ -- OPTIONS request (as detailed below), a client MUST send the target
660
+ -- URI in absolute-form as the request-target.
661
+ -- ...
662
+ -- To allow for transition to the absolute-form for all requests in some
663
+ -- future version of HTTP, a server MUST accept the absolute-form in
664
+ -- requests, even though HTTP/1.1 clients will only send them in
665
+ -- requests to proxies.
666
+ assert (has_authority , " absolute-form requires an authority" )
667
+ if target ~= " *" then
668
+ target = headers :get (" :scheme" ) .. " ://" .. headers :get (" :authority" ) .. target
669
+ else
670
+ target = headers :get (" :scheme" ) .. " ://" .. headers :get (" :authority" )
671
+ end
672
+ end
653
673
end
654
674
if self .connection .req_locked then
655
675
-- Wait until previous request has been fully written
0 commit comments