From ce9699d5c5f948ce09437730d2f24fe77a36d1ac Mon Sep 17 00:00:00 2001 From: rfm Date: Wed, 26 Mar 2025 16:16:57 +0000 Subject: [PATCH] Fixup key name that I advised on incorrectly - needs the correct prefix. --- ChangeLog | 8 ++++++-- Headers/Foundation/NSURLHandle.h | 4 ++-- Source/GSHTTPURLHandle.m | 34 ++++++++++++++++++-------------- Source/NSURLProtocol.m | 10 ++++++---- Source/externs.m | 2 +- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6312e59d8..80bf52ccf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,9 +3,13 @@ * Sources/externs.m: * Source/GSHTTPURLHandle.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. - 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 diff --git a/Headers/Foundation/NSURLHandle.h b/Headers/Foundation/NSURLHandle.h index 68bf6250b..9a7c008c9 100644 --- a/Headers/Foundation/NSURLHandle.h +++ b/Headers/Foundation/NSURLHandle.h @@ -116,11 +116,11 @@ GS_EXPORT NSString * const GSHTTPPropertyPasswordKey; /** * Key for passing to [NSURLHandle]'s and [NSHTTPURLProtocol]'s - * propertyForKey.. methods. Specifying @YES will + * propertyForKey.. methods. Specifying YES will * signal Digest Authentication logic to always omit the 'query' portion of the * URI when generating the `Authorization` header. */ -GS_EXPORT NSString * const GSDigestURIOmitsQuery; +GS_EXPORT NSString * const GSHTTPPropertyDigestURIOmitsQuery; #endif diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index 7e85bb853..6173764c2 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -574,15 +574,17 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data) } } - omitQuery = [request objectForKey:GSDigestURIOmitsQuery]; + omitQuery = [request objectForKey: + GSHTTPPropertyDigestURIOmitsQuery]; if ([[u query] length] == 0 || [omitQuery boolValue]) { - path = [u pathWithEscapes]; - } - else - { - path = [NSString stringWithFormat:@"%@?%@", [u pathWithEscapes], [u query]]; - } + path = [u pathWithEscapes]; + } + else + { + path = [NSString stringWithFormat: @"%@?%@", + [u pathWithEscapes], [u query]]; + } auth = [authentication authorizationForAuthentication: nil 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]) - { - path = [url pathWithEscapes]; - } - else - { - path = [NSString stringWithFormat:@"%@?%@", [url pathWithEscapes], [url query]]; - } + { + path = [url pathWithEscapes]; + } + else + { + path = [NSString stringWithFormat: @"%@?%@", + [url pathWithEscapes], [url query]]; + } auth = [authentication authorizationForAuthentication: ac method: method diff --git a/Source/NSURLProtocol.m b/Source/NSURLProtocol.m index a7ed3a69a..7e8c46afa 100644 --- a/Source/NSURLProtocol.m +++ b/Source/NSURLProtocol.m @@ -1411,13 +1411,15 @@ typedef struct { /* Generate authentication header value for the * authentication type in the challenge. */ - omitQuery = [this->request _propertyForKey:GSDigestURIOmitsQuery]; + omitQuery = [this->request _propertyForKey: + GSHTTPPropertyDigestURIOmitsQuery]; auth = [authentication authorizationForAuthentication: hdr method: [this->request HTTPMethod] - path: [[url query] length] == 0 || [omitQuery boolValue] ? - [url pathWithEscapes] : - [NSString stringWithFormat:@"%@?%@", [url pathWithEscapes], [url query]] + path: [[url query] length] == 0 || [omitQuery boolValue] + ? [url pathWithEscapes] + : [NSString stringWithFormat: @"%@?%@", + [url pathWithEscapes], [url query]] ]; } diff --git a/Source/externs.m b/Source/externs.m index abbc6351a..8a9f41fcd 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -562,7 +562,7 @@ GS_DECLARE NSString* const GSHTTPPropertyProxyPortKey = @"GSHTTPPropertyProxyPor GS_DECLARE NSString* const GSHTTPPropertyCertificateFileKey = @"GSHTTPPropertyCertificateFileKey"; GS_DECLARE NSString* const GSHTTPPropertyKeyFileKey = @"GSHTTPPropertyKeyFileKey"; GS_DECLARE NSString* const GSHTTPPropertyPasswordKey = @"GSHTTPPropertyPasswordKey"; -GS_DECLARE NSString* const GSDigestURIOmitsQuery = @"GSDigestURIOmitsQuery"; +GS_DECLARE NSString* const GSHTTPPropertyDigestURIOmitsQuery = @"GSHTTPPropertyDigestURIOmitsQuery"; /* NSURLProtectionSpace */ GS_DECLARE NSString* const NSURLProtectionSpaceFTPProxy = @"ftp";