Fixup key name that I advised on incorrectly - needs the correct prefix.

This commit is contained in:
rfm 2025-03-26 16:16:57 +00:00
parent 62ab252a3f
commit ce9699d5c5
5 changed files with 34 additions and 24 deletions

View file

@ -3,9 +3,13 @@
* Sources/externs.m: * Sources/externs.m:
* Source/GSHTTPURLHandle.m: * Source/GSHTTPURLHandle.m:
* Source/NSURLProtocol.m: * Source/NSURLProtocol.m:
Updates `Authorization` header generation to include the query parameters (if present). Updates 'Authorization' header generation to include the query
parameters (if present).
Brings the implementation inline with MacOS. Brings the implementation inline with MacOS.
Also adds the `GSDigestURIOmitsQuery` key for use with ` -[NSHTTPURLHandle writeProperty:forKey:]` / `+[NSURLProtocol setProperty:forKey:inRequest:]` to toggle off this updated behavior. Also adds the 'GSHTTPPropertyDigestURIOmitsQuery' key for use with
'-[NSHTTPURLHandle writeProperty:forKey:]' or
'+[NSURLProtocol setProperty:forKey:inRequest:]' to toggle off this
updated behavior.
2025-03-08 Richard Frith-Macdonald <rfm@gnu.org> 2025-03-08 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -116,11 +116,11 @@ GS_EXPORT NSString * const GSHTTPPropertyPasswordKey;
/** /**
* Key for passing to [NSURLHandle]'s and [NSHTTPURLProtocol]'s * Key for passing to [NSURLHandle]'s and [NSHTTPURLProtocol]'s
* <code>propertyForKey..</code> methods. Specifying <code>@YES</code> will * <code>propertyForKey..</code> methods. Specifying <code>YES</code> will
* signal Digest Authentication logic to always omit the 'query' portion of the * signal Digest Authentication logic to always omit the 'query' portion of the
* URI when generating the `Authorization` header. * URI when generating the `Authorization` header.
*/ */
GS_EXPORT NSString * const GSDigestURIOmitsQuery; GS_EXPORT NSString * const GSHTTPPropertyDigestURIOmitsQuery;
#endif #endif

View file

@ -574,15 +574,17 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
} }
} }
omitQuery = [request objectForKey:GSDigestURIOmitsQuery]; omitQuery = [request objectForKey:
GSHTTPPropertyDigestURIOmitsQuery];
if ([[u query] length] == 0 || [omitQuery boolValue]) if ([[u query] length] == 0 || [omitQuery boolValue])
{ {
path = [u pathWithEscapes]; path = [u pathWithEscapes];
} }
else else
{ {
path = [NSString stringWithFormat:@"%@?%@", [u pathWithEscapes], [u query]]; path = [NSString stringWithFormat: @"%@?%@",
} [u pathWithEscapes], [u query]];
}
auth = [authentication authorizationForAuthentication: nil auth = [authentication authorizationForAuthentication: nil
method: method method: method
@ -905,15 +907,17 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
} }
} }
omitQuery = [request objectForKey:GSDigestURIOmitsQuery]; omitQuery = [request objectForKey:
GSHTTPPropertyDigestURIOmitsQuery];
if ([[url query] length] == 0 || [omitQuery boolValue]) if ([[url query] length] == 0 || [omitQuery boolValue])
{ {
path = [url pathWithEscapes]; path = [url pathWithEscapes];
} }
else else
{ {
path = [NSString stringWithFormat:@"%@?%@", [url pathWithEscapes], [url query]]; path = [NSString stringWithFormat: @"%@?%@",
} [url pathWithEscapes], [url query]];
}
auth = [authentication authorizationForAuthentication: ac auth = [authentication authorizationForAuthentication: ac
method: method method: method

View file

@ -1411,13 +1411,15 @@ typedef struct {
/* Generate authentication header value for the /* Generate authentication header value for the
* authentication type in the challenge. * authentication type in the challenge.
*/ */
omitQuery = [this->request _propertyForKey:GSDigestURIOmitsQuery]; omitQuery = [this->request _propertyForKey:
GSHTTPPropertyDigestURIOmitsQuery];
auth = [authentication auth = [authentication
authorizationForAuthentication: hdr authorizationForAuthentication: hdr
method: [this->request HTTPMethod] method: [this->request HTTPMethod]
path: [[url query] length] == 0 || [omitQuery boolValue] ? path: [[url query] length] == 0 || [omitQuery boolValue]
[url pathWithEscapes] : ? [url pathWithEscapes]
[NSString stringWithFormat:@"%@?%@", [url pathWithEscapes], [url query]] : [NSString stringWithFormat: @"%@?%@",
[url pathWithEscapes], [url query]]
]; ];
} }

View file

@ -562,7 +562,7 @@ GS_DECLARE NSString* const GSHTTPPropertyProxyPortKey = @"GSHTTPPropertyProxyPor
GS_DECLARE NSString* const GSHTTPPropertyCertificateFileKey = @"GSHTTPPropertyCertificateFileKey"; GS_DECLARE NSString* const GSHTTPPropertyCertificateFileKey = @"GSHTTPPropertyCertificateFileKey";
GS_DECLARE NSString* const GSHTTPPropertyKeyFileKey = @"GSHTTPPropertyKeyFileKey"; GS_DECLARE NSString* const GSHTTPPropertyKeyFileKey = @"GSHTTPPropertyKeyFileKey";
GS_DECLARE NSString* const GSHTTPPropertyPasswordKey = @"GSHTTPPropertyPasswordKey"; GS_DECLARE NSString* const GSHTTPPropertyPasswordKey = @"GSHTTPPropertyPasswordKey";
GS_DECLARE NSString* const GSDigestURIOmitsQuery = @"GSDigestURIOmitsQuery"; GS_DECLARE NSString* const GSHTTPPropertyDigestURIOmitsQuery = @"GSHTTPPropertyDigestURIOmitsQuery";
/* NSURLProtectionSpace */ /* NSURLProtectionSpace */
GS_DECLARE NSString* const NSURLProtectionSpaceFTPProxy = @"ftp"; GS_DECLARE NSString* const NSURLProtectionSpaceFTPProxy = @"ftp";