* Source/GSURLPrivate.h: Addition of private method to NSURLProtocol

category.
	* Source/NSURLConnection.m: Changes to use the new method and to correct
	bug #26107.  Patch by: doug@riverrock.org
	* Source/NSURLProtocol.m: Addition of static method to look up class 
	which can handle the given connection protocol.  
	Patch by: doug@riverrock.org


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28229 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2009-04-18 14:22:54 +00:00
parent e537692852
commit 1be02d0252
4 changed files with 61 additions and 3 deletions

View file

@ -1,3 +1,13 @@
2009-04-18 10:15-EDT Gregory John Casamento <greg.casamento@gmail.com>
* Source/GSURLPrivate.h: Addition of private method to NSURLProtocol
category.
* Source/NSURLConnection.m: Changes to use the new method and to correct
bug #26107. Patch by: doug@riverrock.org
* Source/NSURLProtocol.m: Addition of static method to look up class
which can handle the given connection protocol.
Patch by: doug@riverrock.org
2009-04-16 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSHasTable.h: new OSX 10.5 API

View file

@ -71,6 +71,9 @@
@end
@interface NSURLProtocol (Private)
+ (Class) _classToHandleRequest:(NSURLRequest *)request;
@end
/*
* Internal class for handling HTTP authentication

View file

@ -26,7 +26,6 @@
#import <Foundation/NSDebug.h>
#import "GSURLPrivate.h"
@interface _NSURLConnectionDataCollector : NSObject <NSURLProtocolClient>
{
NSURLConnection *_connection; // Not retained
@ -112,6 +111,13 @@ redirectResponse: (NSURLResponse*)redirectResponse
_done = YES;
}
- (void) connection: (NSURLConnection *)connection
didFailWithError: (NSError *)error
{
*_error = error;
_done = YES;
}
- (void) URLProtocol: (NSURLProtocol*)proto
didReceiveResponse: (NSURLResponse*)response
cacheStoragePolicy: (NSURLCacheStoragePolicy)policy
@ -124,10 +130,29 @@ redirectResponse: (NSURLResponse*)redirectResponse
_done = YES;
}
- (void) connectionDidFinishLoading: (NSURLConnection *)connection
{
_done = YES;
}
- (void) URLProtocol: (NSURLProtocol*)proto
didLoadData: (NSData*)data
{
if (_data != nil)
if (_data == nil)
{
_data = [data mutableCopy];
}
else
{
[_data appendData: data];
}
}
- (void) connection: (NSURLConnection *)connection
didReceiveData: (NSData *)data
{
if (_data == nil)
{
_data = [data mutableCopy];
}
@ -175,7 +200,7 @@ typedef struct {
+ (BOOL) canHandleRequest: (NSURLRequest *)request
{
return [NSURLProtocol canInitWithRequest: request];
return ([NSURLProtocol _classToHandleRequest: request] != nil);
}
+ (NSURLConnection *) connectionWithRequest: (NSURLRequest *)request

View file

@ -341,6 +341,26 @@ static NSURLProtocol *placeholder = nil;
return NO;
}
+(Class) _classToHandleRequest:(NSURLRequest *)request
{
Class protoClass = nil;
[regLock lock];
int count = [registered count];
while (count-- > 0)
{
Class proto = [registered objectAtIndex: count];
if ([proto canInitWithRequest: request] == YES)
{
protoClass = proto;
break;
}
}
[regLock unlock];
return protoClass;
}
+ (void) setProperty: (id)value
forKey: (NSString *)key
inRequest: (NSMutableURLRequest *)request