Skip to content

Commit

Permalink
* Use NSMakeCollectable instead so we can remove the casts
Browse files Browse the repository at this point in the history
* Use [pool drain] because Xcode told us to
* Get rid of a couple of random nib warnings
  • Loading branch information
pokeb committed Aug 6, 2011
1 parent 011cb6d commit ca6df3f
Show file tree
Hide file tree
Showing 3 changed files with 345 additions and 1,100 deletions.
35 changes: 19 additions & 16 deletions Classes/ASIHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import "ASIDataCompressor.h"

// Automatically set on build
NSString *ASIHTTPRequestVersion = @"v1.8.1-13 2011-08-06";
NSString *ASIHTTPRequestVersion = @"v1.8.1-23 2011-08-06";

static NSString *defaultUserAgent = nil;

Expand Down Expand Up @@ -1169,7 +1169,7 @@ - (void)startRequest
} else {
[self setPostBodyReadStream:[ASIInputStream inputStreamWithFileAtPath:[self postBodyFilePath] request:self]];
}
[self setReadStream:[(NSInputStream *)CFMakeCollectable(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream])) autorelease]];
[self setReadStream:[NSMakeCollectable(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream])) autorelease]];
} else {

// If we have a request body, we'll stream it from memory using our custom stream, so that we can measure bandwidth use and it can be bandwidth-throttled if necessary
Expand All @@ -1179,10 +1179,10 @@ - (void)startRequest
} else if ([self postBody]) {
[self setPostBodyReadStream:[ASIInputStream inputStreamWithData:[self postBody] request:self]];
}
[self setReadStream:[(NSInputStream *)CFMakeCollectable(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream])) autorelease]];
[self setReadStream:[NSMakeCollectable(CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, request,(CFReadStreamRef)[self postBodyReadStream])) autorelease]];

} else {
[self setReadStream:[(NSInputStream *)CFMakeCollectable(CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request)) autorelease]];
[self setReadStream:[NSMakeCollectable(CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request)) autorelease]];
}
}

Expand Down Expand Up @@ -2132,9 +2132,9 @@ - (void)readResponseHeaders
}
#endif

[self setResponseHeaders:[(NSDictionary *)CFMakeCollectable(CFHTTPMessageCopyAllHeaderFields(message)) autorelease]];
[self setResponseHeaders:[NSMakeCollectable(CFHTTPMessageCopyAllHeaderFields(message)) autorelease]];
[self setResponseStatusCode:(int)CFHTTPMessageGetResponseStatusCode(message)];
[self setResponseStatusMessage:[(NSString *)CFMakeCollectable(CFHTTPMessageCopyResponseStatusLine(message)) autorelease]];
[self setResponseStatusMessage:[NSMakeCollectable(CFHTTPMessageCopyResponseStatusLine(message)) autorelease]];

if ([self downloadCache] && ([[self downloadCache] canUseCachedDataForRequest:self])) {

Expand Down Expand Up @@ -2749,7 +2749,7 @@ - (void)attemptToApplyProxyCredentialsAndResume
CFHTTPMessageRef responseHeader = (CFHTTPMessageRef) CFReadStreamCopyProperty((CFReadStreamRef)[self readStream],kCFStreamPropertyHTTPResponseHeader);
proxyAuthentication = CFHTTPAuthenticationCreateFromResponse(NULL, responseHeader);
CFRelease(responseHeader);
[self setProxyAuthenticationScheme:[(NSString *)CFMakeCollectable(CFHTTPAuthenticationCopyMethod(proxyAuthentication)) autorelease]];
[self setProxyAuthenticationScheme:[NSMakeCollectable(CFHTTPAuthenticationCopyMethod(proxyAuthentication)) autorelease]];
}

// If we haven't got a CFHTTPAuthenticationRef by now, something is badly wrong, so we'll have to give up
Expand All @@ -2762,7 +2762,7 @@ - (void)attemptToApplyProxyCredentialsAndResume
// Get the authentication realm
[self setProxyAuthenticationRealm:nil];
if (!CFHTTPAuthenticationRequiresAccountDomain(proxyAuthentication)) {
[self setProxyAuthenticationRealm:[(NSString *)CFMakeCollectable(CFHTTPAuthenticationCopyRealm(proxyAuthentication)) autorelease]];
[self setProxyAuthenticationRealm:[NSMakeCollectable(CFHTTPAuthenticationCopyRealm(proxyAuthentication)) autorelease]];
}

// See if authentication is valid
Expand Down Expand Up @@ -2926,7 +2926,7 @@ - (void)attemptToApplyCredentialsAndResume
CFHTTPMessageRef responseHeader = (CFHTTPMessageRef) CFReadStreamCopyProperty((CFReadStreamRef)[self readStream],kCFStreamPropertyHTTPResponseHeader);
requestAuthentication = CFHTTPAuthenticationCreateFromResponse(NULL, responseHeader);
CFRelease(responseHeader);
[self setAuthenticationScheme:[(NSString *)CFMakeCollectable(CFHTTPAuthenticationCopyMethod(requestAuthentication)) autorelease]];
[self setAuthenticationScheme:[NSMakeCollectable(CFHTTPAuthenticationCopyMethod(requestAuthentication)) autorelease]];
}

if (!requestAuthentication) {
Expand All @@ -2942,7 +2942,7 @@ - (void)attemptToApplyCredentialsAndResume
// Get the authentication realm
[self setAuthenticationRealm:nil];
if (!CFHTTPAuthenticationRequiresAccountDomain(requestAuthentication)) {
[self setAuthenticationRealm:[(NSString *)CFMakeCollectable(CFHTTPAuthenticationCopyRealm(requestAuthentication)) autorelease]];
[self setAuthenticationRealm:[NSMakeCollectable(CFHTTPAuthenticationCopyRealm(requestAuthentication)) autorelease]];
}

#if DEBUG_HTTP_AUTHENTICATION
Expand Down Expand Up @@ -3159,7 +3159,7 @@ - (void)handleNetworkEvent:(CFStreamEventType)type

if ([self complete] || [self isCancelled]) {
[[self cancelledLock] unlock];
[pool release];
[pool drain];
return;
}

Expand Down Expand Up @@ -3196,7 +3196,7 @@ - (void)handleNetworkEvent:(CFStreamEventType)type
}

CFRelease(self);
[pool release];
[pool drain];
}

- (BOOL)willAskDelegateToConfirmRedirect
Expand Down Expand Up @@ -3507,13 +3507,16 @@ - (void)markAsFinished

// dealloc won't be called when running with GC, so we'll clean these up now
if (request) {
CFMakeCollectable(request);
CFRelease(request);
request = nil;
}
if (requestAuthentication) {
CFMakeCollectable(requestAuthentication);
CFRelease(requestAuthentication);
requestAuthentication = nil;
}
if (proxyAuthentication) {
CFMakeCollectable(proxyAuthentication);
CFRelease(proxyAuthentication);
proxyAuthentication = nil;
}

BOOL wasInProgress = inProgress;
Expand Down Expand Up @@ -4771,7 +4774,7 @@ + (void)runRequests
while (runAlways) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
CFRunLoopRun();
[pool release];
[pool drain];
}

// Should never be called, but anyway
Expand Down
Loading

0 comments on commit ca6df3f

Please sign in to comment.