mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Apply patches by Lubomir Rintel <lubo.rintel@gooddata.com> to enable cookies
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34746 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
06ba8d9c58
commit
8b2aba3580
6 changed files with 105 additions and 14 deletions
|
@ -115,10 +115,9 @@
|
|||
|
||||
@end
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NSURLRequest *_request;
|
||||
NSMutableURLRequest *_request;
|
||||
NSURLProtocol *_protocol;
|
||||
id _delegate; // Not retained
|
||||
BOOL _debug;
|
||||
|
@ -190,7 +189,33 @@ typedef struct
|
|||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
this->_request = [request copy];
|
||||
this->_request = [request mutableCopyWithZone: [self zone]];
|
||||
|
||||
/* Enrich the request with the appropriate HTTP cookies,
|
||||
* if desired.
|
||||
*/
|
||||
if ([this->_request HTTPShouldHandleCookies] == YES)
|
||||
{
|
||||
NSArray *cookies;
|
||||
|
||||
cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage]
|
||||
cookiesForURL: [this->_request URL]];
|
||||
if ([cookies count] > 0)
|
||||
{
|
||||
NSDictionary *headers;
|
||||
NSEnumerator *enumerator;
|
||||
NSString *header;
|
||||
|
||||
headers = [NSHTTPCookie requestHeaderFieldsWithCookies: cookies];
|
||||
enumerator = [headers keyEnumerator];
|
||||
while (nil != (header = [enumerator nextObject]))
|
||||
{
|
||||
[this->_request addValue: [headers valueForKey: header]
|
||||
forHTTPHeaderField: header];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->_delegate = delegate;
|
||||
this->_protocol = [[NSURLProtocol alloc]
|
||||
initWithRequest: this->_request
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue