mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Fix Authorization
header generation
Fixes `Authorization` header generation to include the query parameters (if present). This brings the implementation inline with MacOS, and fixes digest auth with certain picky services.
This commit is contained in:
parent
80b54d580d
commit
dc4270128d
3 changed files with 32 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
|||
2025-03-21 Earl Robsham <earl.robsham@savant.com>
|
||||
* Source/GSHTTPURLHandle.m:
|
||||
* Source/NSURLProtocol.m:
|
||||
Updates `Authorization` header generation to include the query parameters (if present).
|
||||
Brings the implementation inline with MacOS.
|
||||
|
||||
2025-03-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/GNUstepBase/GSObjCRuntime.h:
|
||||
|
|
|
@ -535,6 +535,7 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
GSHTTPAuthentication *authentication;
|
||||
NSURLCredential *cred;
|
||||
NSString *method;
|
||||
NSString *path;
|
||||
|
||||
/* Create credential from user and password stored in the URL.
|
||||
* Returns nil if we have no username or password.
|
||||
|
@ -572,9 +573,18 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
}
|
||||
}
|
||||
|
||||
if ([[u query] length] == 0)
|
||||
{
|
||||
path = [u pathWithEscapes];
|
||||
}
|
||||
else
|
||||
{
|
||||
path = [NSString stringWithFormat:@"%@?%@", [u pathWithEscapes], [u query]];
|
||||
}
|
||||
|
||||
auth = [authentication authorizationForAuthentication: nil
|
||||
method: method
|
||||
path: [u pathWithEscapes]];
|
||||
path: path];
|
||||
/* If authentication is nil then auth will also be nil
|
||||
*/
|
||||
if (auth != nil)
|
||||
|
@ -837,6 +847,7 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
NSString *ac;
|
||||
GSHTTPAuthentication *authentication;
|
||||
NSString *method;
|
||||
NSString *path;
|
||||
NSString *auth;
|
||||
|
||||
ac = [ah value];
|
||||
|
@ -891,9 +902,18 @@ debugWrite(GSHTTPURLHandle *handle, NSData *data)
|
|||
}
|
||||
}
|
||||
|
||||
if ([[url query] length] == 0)
|
||||
{
|
||||
path = [url pathWithEscapes];
|
||||
}
|
||||
else
|
||||
{
|
||||
path = [NSString stringWithFormat:@"%@?%@", [url pathWithEscapes], [url query]];
|
||||
}
|
||||
|
||||
auth = [authentication authorizationForAuthentication: ac
|
||||
method: method
|
||||
path: [url pathWithEscapes]];
|
||||
path: path];
|
||||
if (auth != nil)
|
||||
{
|
||||
[self writeProperty: auth forKey: @"Authorization"];
|
||||
|
|
|
@ -1413,7 +1413,10 @@ typedef struct {
|
|||
auth = [authentication
|
||||
authorizationForAuthentication: hdr
|
||||
method: [this->request HTTPMethod]
|
||||
path: [url pathWithEscapes]];
|
||||
path: [[url query] length] == 0 ?
|
||||
[url pathWithEscapes] :
|
||||
[NSString stringWithFormat:@"%@?%@", [url pathWithEscapes], [url query]]
|
||||
];
|
||||
}
|
||||
|
||||
if (auth == nil)
|
||||
|
|
Loading…
Reference in a new issue