Request.url should return nil for situations where it is not applicable (#84)

Regular CONNECT requests and OPTIONS * requests do not have URLs
This commit is contained in:
Guoye Zhang authored and GitHub committed 2025-01-29 07:10:41 +00:00
1 parent 74191f0834
commit 40ca463b5f
2 files changed
+30

No files matched your search

@@ -24,6 +24,11 @@ extension HTTPRequest {
/// fields.
public var url: URL? {
get {
if (self.method == .connect && self.extendedConnectProtocol == nil)
|| (self.method == .options && self.path == "*")
{
return nil
}
if let schemeField = self.pseudoHeaderFields.scheme,
let authorityField = self.pseudoHeaderFields.authority,
let pathField = self.pseudoHeaderFields.path