Ben Copsey

Made receivedData an NSMutableData object, to save all the casting

Changed url format in tests
Small layout cleanups in the nib
Added reference to the new documentation page
... ... @@ -4,6 +4,9 @@
// Created by Ben Copsey on 04/10/2007.
// Copyright 2007-2008 All-Seeing Interactive. All rights reserved.
//
// A guide to the main features is available at:
// http://allseeing-i.com/asi-http-request
//
// Portions are based on the ImageClient example from Apple:
// See: http://developer.apple.com/samplecode/ImageClient/listing37.html
... ... @@ -68,7 +71,7 @@
BOOL haveExaminedHeaders;
//Data we receive will be stored here
CFMutableDataRef receivedData;
NSMutableData *receivedData;
//Used for sending and receiving data
CFHTTPMessageRef request;
... ... @@ -228,6 +231,6 @@
@property (retain) NSDictionary *responseHeaders;
@property (retain) NSDictionary *requestCredentials;
@property (assign) int responseStatusCode;
@property (retain) NSMutableData *receivedData;
@end
... ...
... ... @@ -4,6 +4,9 @@
// Created by Ben Copsey on 04/10/2007.
// Copyright 2007-2008 All-Seeing Interactive. All rights reserved.
//
// A guide to the main features is available at:
// http://allseeing-i.com/asi-http-request
//
// Portions are based on the ImageClient example from Apple:
// See: http://developer.apple.com/samplecode/ImageClient/listing37.html
... ... @@ -46,7 +49,7 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
//credentials = NULL;
request = NULL;
responseHeaders = nil;
[self setUseKeychainPersistance:YES];
[self setUseKeychainPersistance:NO];
[self setUseSessionPersistance:YES];
didFinishSelector = @selector(requestFinished:);
didFailSelector = @selector(requestFailed:);
... ... @@ -135,7 +138,7 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
if (!receivedData) {
return nil;
}
return [[[NSString alloc] initWithBytes:[(NSData *)receivedData bytes] length:[(NSData *)receivedData length] encoding:NSUTF8StringEncoding] autorelease];
return [[[NSString alloc] initWithBytes:[receivedData bytes] length:[receivedData length] encoding:NSUTF8StringEncoding] autorelease];
}
... ... @@ -237,7 +240,7 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
lastBytesSent = 0;
contentLength = 0;
[self setResponseHeaders:nil];
receivedData = CFDataCreateMutable(NULL, 0);
[self setReceivedData:[[[NSMutableData alloc] init] autorelease]];
// Create the stream for the request.
readStream = CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,readStream);
... ... @@ -302,8 +305,7 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
}
if (receivedData) {
CFRelease(receivedData);
receivedData = NULL;
[self setReceivedData:nil];
//If we were downloading to a file, let's remove it
} else if (downloadDestinationPath) {
... ... @@ -659,7 +661,7 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
//Otherwise, let's add the data to our in-memory store
} else {
CFDataAppendBytes(receivedData, buffer, bytesRead);
[receivedData appendBytes:buffer length:bytesRead];
}
}
}
... ... @@ -778,4 +780,5 @@ static void ReadStreamClientCallBack(CFReadStreamRef readStream, CFStreamEventTy
@synthesize responseHeaders;
@synthesize requestCredentials;
@synthesize responseStatusCode;
@synthesize receivedData;
@end
... ...
... ... @@ -62,15 +62,15 @@ More tests needed for:
NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
NSURL *url;
url = [[[NSURL alloc] initWithString:@"http:/allseeing-i.com/asi-http-request-tests/first"] autorelease];
url = [[[NSURL alloc] initWithString:@"http:/allseeing-i.com/asi-http-request/tests/first"] autorelease];
ASIHTTPRequest *request1 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[queue addOperation:request1];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request-tests/second"] autorelease];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/second"] autorelease];
ASIHTTPRequest *request2 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[queue addOperation:request2];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request-tests/third"] autorelease];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/third"] autorelease];
ASIHTTPRequest *request3 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[queue addOperation:request3];
... ... @@ -78,7 +78,7 @@ More tests needed for:
ASIHTTPRequest *request4 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[queue addOperation:request4];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request-tests/broken"] autorelease];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/broken"] autorelease];
ASIHTTPRequest *request5 = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[queue addOperation:request5];
... ...
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff was suppressed by a .gitattributes entry.