Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of https://github.com/mindsnacks/asi-http-request

… into mindsnacks-master

Conflicts:
	Classes/ASIHTTPRequest.m
  • Loading branch information...
commit 232d6991fcc73f002f42de1f82de926fa6da4532 2 parents e2f2815 + afa74b6
Ben Copsey authored
2  Classes/ASIFormDataRequest.m
View
@@ -207,7 +207,7 @@ - (void)buildPostBody
[super buildPostBody];
#if DEBUG_FORM_DATA_REQUEST
- NSLog(@"%@",[self debugBodyString]);
+ ASI_DEBUG_LOG(@"%@",[self debugBodyString]);
[self setDebugBodyString:nil];
#endif
}
106 Classes/ASIHTTPRequest.m
View
@@ -696,7 +696,7 @@ - (void)setQueue:(id)newQueue
- (void)cancelOnRequestThread
{
#if DEBUG_REQUEST_STATUS
- NSLog(@"[STATUS] Request cancelled: %@",self);
+ ASI_DEBUG_LOG(@"[STATUS] Request cancelled: %@",self);
#endif
[[self cancelledLock] lock];
@@ -786,7 +786,7 @@ - (NSData *)responseData
- (void)startSynchronous
{
#if DEBUG_REQUEST_STATUS || DEBUG_THROTTLING
- NSLog(@"[STATUS] Starting synchronous request %@",self);
+ ASI_DEBUG_LOG(@"[STATUS] Starting synchronous request %@",self);
#endif
[self setSynchronous:YES];
[self setRunLoopMode:ASIHTTPRequestRunLoopMode];
@@ -811,7 +811,7 @@ - (void)start
- (void)startAsynchronous
{
#if DEBUG_REQUEST_STATUS || DEBUG_THROTTLING
- NSLog(@"[STATUS] Starting asynchronous request %@",self);
+ ASI_DEBUG_LOG(@"[STATUS] Starting asynchronous request %@",self);
#endif
[sharedQueue addOperation:self];
}
@@ -962,7 +962,7 @@ - (void)applyAuthorizationHeader
// Do we want to send credentials before we are asked for them?
if (![self shouldPresentCredentialsBeforeChallenge]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will not send credentials to the server until it asks for them",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will not send credentials to the server until it asks for them",self);
#endif
return;
}
@@ -977,7 +977,7 @@ - (void)applyAuthorizationHeader
[self addBasicAuthenticationHeaderWithUsername:[self username] andPassword:[self password]];
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ has a username and password set, and was manually configured to use BASIC. Will send credentials without waiting for an authentication challenge",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ has a username and password set, and was manually configured to use BASIC. Will send credentials without waiting for an authentication challenge",self);
#endif
} else {
@@ -996,12 +996,12 @@ - (void)applyAuthorizationHeader
if (CFHTTPMessageApplyCredentialDictionary(request, (CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) {
[self setAuthenticationScheme:[credentials objectForKey:@"AuthenticationScheme"]];
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ found cached credentials (%@), will reuse without waiting for an authentication challenge",self,[credentials objectForKey:@"AuthenticationScheme"]);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ found cached credentials (%@), will reuse without waiting for an authentication challenge",self,[credentials objectForKey:@"AuthenticationScheme"]);
#endif
} else {
[[self class] removeAuthenticationCredentialsFromSessionStore:[credentials objectForKey:@"Credentials"]];
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Failed to apply cached credentials to request %@. These will be removed from the session store, and this request will wait for an authentication challenge",self);
+ ASI_DEBUG_LOG(@"[AUTH] Failed to apply cached credentials to request %@. These will be removed from the session store, and this request will wait for an authentication challenge",self);
#endif
}
@@ -1011,7 +1011,7 @@ - (void)applyAuthorizationHeader
NSDictionary *usernameAndPassword = [credentials objectForKey:@"Credentials"];
[self addBasicAuthenticationHeaderWithUsername:[usernameAndPassword objectForKey:(NSString *)kCFHTTPAuthenticationUsername] andPassword:[usernameAndPassword objectForKey:(NSString *)kCFHTTPAuthenticationPassword]];
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ found cached BASIC credentials from a previous request. Will send credentials without waiting for an authentication challenge",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ found cached BASIC credentials from a previous request. Will send credentials without waiting for an authentication challenge",self);
#endif
}
}
@@ -1288,7 +1288,7 @@ - (void)startRequest
// Check if we should have expired this connection
} else if ([[[self connectionInfo] objectForKey:@"expires"] timeIntervalSinceNow] < 0) {
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Not re-using connection #%i because it has expired",[[[self connectionInfo] objectForKey:@"id"] intValue]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Not re-using connection #%i because it has expired",[[[self connectionInfo] objectForKey:@"id"] intValue]);
#endif
[persistentConnectionsPool removeObject:[self connectionInfo]];
[self setConnectionInfo:nil];
@@ -1296,7 +1296,7 @@ - (void)startRequest
} else if ([[self connectionInfo] objectForKey:@"request"] != nil) {
//Some other request reused this connection already - we'll have to create a new one
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"%@ - Not re-using connection #%i for request #%i because it is already used by request #%i",self,[[[self connectionInfo] objectForKey:@"id"] intValue],[[self requestID] intValue],[[[self connectionInfo] objectForKey:@"request"] intValue]);
+ ASI_DEBUG_LOG(@"%@ - Not re-using connection #%i for request #%i because it is already used by request #%i",self,[[[self connectionInfo] objectForKey:@"id"] intValue],[[self requestID] intValue],[[[self connectionInfo] objectForKey:@"request"] intValue]);
#endif
[self setConnectionInfo:nil];
}
@@ -1340,7 +1340,7 @@ - (void)startRequest
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue);
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Request #%@ will use connection #%i",[self requestID],[[[self connectionInfo] objectForKey:@"id"] intValue]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Request #%@ will use connection #%i",[self requestID],[[[self connectionInfo] objectForKey:@"id"] intValue]);
#endif
@@ -1351,7 +1351,7 @@ - (void)startRequest
} else {
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Request %@ will not use a persistent connection",self);
+ ASI_DEBUG_LOG(@"[CONNECTION] Request %@ will not use a persistent connection",self);
#endif
}
@@ -1528,7 +1528,7 @@ - (void)checkRequestStatus
#if DEBUG_REQUEST_STATUS
if ([self totalBytesSent] == [self postLength]) {
- NSLog(@"[STATUS] Request %@ finished uploading data",self);
+ ASI_DEBUG_LOG(@"[STATUS] Request %@ finished uploading data",self);
}
#endif
}
@@ -1985,7 +1985,7 @@ - (void)requestWillRedirectToURL:(NSURL *)newURL
- (void)requestFinished
{
#if DEBUG_REQUEST_STATUS || DEBUG_THROTTLING
- NSLog(@"[STATUS] Request finished: %@",self);
+ ASI_DEBUG_LOG(@"[STATUS] Request finished: %@",self);
#endif
if ([self error] || [self mainRequest]) {
return;
@@ -2052,7 +2052,7 @@ - (void)passOnReceivedData:(NSData *)data
- (void)failWithError:(NSError *)theError
{
#if DEBUG_REQUEST_STATUS || DEBUG_THROTTLING
- NSLog(@"[STATUS] Request %@: %@",self,(theError == ASIRequestCancelledError ? @"Cancelled" : @"Failed"));
+ ASI_DEBUG_LOG(@"[STATUS] Request %@: %@",self,(theError == ASIRequestCancelledError ? @"Cancelled" : @"Failed"));
#endif
[self setComplete:YES];
@@ -2060,7 +2060,7 @@ - (void)failWithError:(NSError *)theError
if (theError && [theError code] != ASIAuthenticationErrorType && [theError code] != ASITooMuchRedirectionErrorType) {
[connectionsLock lock];
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Request #%@ failed and will invalidate connection #%@",[self requestID],[[self connectionInfo] objectForKey:@"id"]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Request #%@ failed and will invalidate connection #%@",[self requestID],[[self connectionInfo] objectForKey:@"id"]);
#endif
[[self connectionInfo] removeObjectForKey:@"request"];
[persistentConnectionsPool removeObject:[self connectionInfo]];
@@ -2128,7 +2128,7 @@ - (void)readResponseHeaders
#if DEBUG_REQUEST_STATUS
if ([self totalBytesSent] == [self postLength]) {
- NSLog(@"[STATUS] Request %@ received response headers",self);
+ ASI_DEBUG_LOG(@"[STATUS] Request %@ received response headers",self);
}
#endif
@@ -2156,7 +2156,7 @@ - (void)readResponseHeaders
} else {
#if DEBUG_HTTP_AUTHENTICATION
if ([self authenticationScheme]) {
- NSLog(@"[AUTH] Request %@ has passed %@ authentication",self,[self authenticationScheme]);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ has passed %@ authentication",self,[self authenticationScheme]);
}
#endif
}
@@ -2168,7 +2168,7 @@ - (void)readResponseHeaders
if (!requestAuthentication && [[self authenticationScheme] isEqualToString:(NSString *)kCFHTTPAuthenticationSchemeBasic] && [self username] && [self password] && [self useSessionPersistence]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ passed BASIC authentication, and will save credentials in the session store for future use",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ passed BASIC authentication, and will save credentials in the session store for future use",self);
#endif
NSMutableDictionary *newCredentials = [NSMutableDictionary dictionaryWithCapacity:2];
@@ -2262,7 +2262,7 @@ - (void)readResponseHeaders
[self setConnectionCanBeReused:YES];
[self setPersistentConnectionTimeoutSeconds:timeout];
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Got a keep-alive header, will keep this connection open for %f seconds", [self persistentConnectionTimeoutSeconds]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Got a keep-alive header, will keep this connection open for %f seconds", [self persistentConnectionTimeoutSeconds]);
#endif
}
@@ -2270,7 +2270,7 @@ - (void)readResponseHeaders
} else {
[self setConnectionCanBeReused:YES];
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Got no keep-alive header, will keep this connection open for %f seconds", [self persistentConnectionTimeoutSeconds]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Got no keep-alive header, will keep this connection open for %f seconds", [self persistentConnectionTimeoutSeconds]);
#endif
}
}
@@ -2334,7 +2334,7 @@ - (BOOL)willRedirect
[self setRequestCookies:[NSMutableArray array]];
#if DEBUG_REQUEST_STATUS
- NSLog(@"[STATUS] Request will redirect (code: %i): %@",responseCode,self);
+ ASI_DEBUG_LOG(@"[STATUS] Request will redirect (code: %i): %@",responseCode,self);
#endif
return YES;
@@ -2523,7 +2523,7 @@ - (NSMutableDictionary *)findCredentials
if (user && pass) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will use credentials set on its url",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will use credentials set on its url",self);
#endif
} else {
@@ -2534,7 +2534,7 @@ - (NSMutableDictionary *)findCredentials
pass = [[self mainRequest] password];
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will use credentials from its parent request",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will use credentials from its parent request",self);
#endif
// Let's try to use the ones set in this object
@@ -2543,7 +2543,7 @@ - (NSMutableDictionary *)findCredentials
pass = [self password];
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will use username and password properties as credentials",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will use username and password properties as credentials",self);
#endif
}
}
@@ -2556,7 +2556,7 @@ - (NSMutableDictionary *)findCredentials
pass = [authenticationCredentials password];
#if DEBUG_HTTP_AUTHENTICATION
if (user && pass) {
- NSLog(@"[AUTH] Request %@ will use credentials from the keychain",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will use credentials from the keychain",self);
}
#endif
}
@@ -2592,7 +2592,7 @@ - (NSMutableDictionary *)findCredentials
- (void)retryUsingSuppliedCredentials
{
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ received credentials from its delegate or an ASIAuthenticationDialog, will retry",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ received credentials from its delegate or an ASIAuthenticationDialog, will retry",self);
#endif
//If the url was changed by the delegate, our CFHTTPMessageRef will be NULL and we'll go back to the start
if (!request) {
@@ -2606,7 +2606,7 @@ - (void)retryUsingSuppliedCredentials
- (void)cancelAuthentication
{
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ had authentication cancelled by its delegate or an ASIAuthenticationDialog",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ had authentication cancelled by its delegate or an ASIAuthenticationDialog",self);
#endif
[self performSelector:@selector(failAuthentication) onThread:[[self class] threadForRequest:self] withObject:nil waitUntilDone:NO];
}
@@ -2931,7 +2931,7 @@ - (void)attemptToApplyCredentialsAndResume
if (!requestAuthentication) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ failed to read authentication information from response headers",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ failed to read authentication information from response headers",self);
#endif
[self cancelLoad];
@@ -2953,9 +2953,9 @@ - (void)attemptToApplyCredentialsAndResume
realm = @"";
}
if ([self authenticationScheme] != (NSString *)kCFHTTPAuthenticationSchemeNTLM || [self authenticationRetryCount] == 0) {
- NSLog(@"[AUTH] Request %@ received 401 challenge and must authenticate using %@%@",self,[self authenticationScheme],realm);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ received 401 challenge and must authenticate using %@%@",self,[self authenticationScheme],realm);
} else {
- NSLog(@"[AUTH] Request %@ NTLM handshake step %i",self,[self authenticationRetryCount]+1);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ NTLM handshake step %i",self,[self authenticationRetryCount]+1);
}
#endif
@@ -2970,7 +2970,7 @@ - (void)attemptToApplyCredentialsAndResume
if (err.domain == kCFStreamErrorDomainHTTP && (err.error == kCFStreamErrorHTTPAuthenticationBadUserName || err.error == kCFStreamErrorHTTPAuthenticationBadPassword)) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ had bad credentials, will remove them from the session store if they are cached",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ had bad credentials, will remove them from the session store if they are cached",self);
#endif
// Prevent more than one request from asking for credentials at once
@@ -2984,7 +2984,7 @@ - (void)attemptToApplyCredentialsAndResume
if ([self error] || [self isCancelled]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ failed or was cancelled while waiting to access credentials",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ failed or was cancelled while waiting to access credentials",self);
#endif
[delegateAuthenticationLock unlock];
@@ -2997,7 +2997,7 @@ - (void)attemptToApplyCredentialsAndResume
if (credentials && [self applyCredentials:[credentials objectForKey:@"Credentials"]]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will reuse cached credentials from the session (%@)",self,[credentials objectForKey:@"AuthenticationScheme"]);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will reuse cached credentials from the session (%@)",self,[credentials objectForKey:@"AuthenticationScheme"]);
#endif
[delegateAuthenticationLock unlock];
@@ -3011,7 +3011,7 @@ - (void)attemptToApplyCredentialsAndResume
if ([self willAskDelegateForCredentials]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will ask its delegate for credentials to use",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will ask its delegate for credentials to use",self);
#endif
[delegateAuthenticationLock unlock];
@@ -3020,7 +3020,7 @@ - (void)attemptToApplyCredentialsAndResume
if ([self showAuthenticationDialog]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will ask ASIAuthenticationDialog for credentials",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will ask ASIAuthenticationDialog for credentials",self);
#endif
[delegateAuthenticationLock unlock];
@@ -3030,7 +3030,7 @@ - (void)attemptToApplyCredentialsAndResume
}
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ has no credentials to present and must give up",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ has no credentials to present and must give up",self);
#endif
[self cancelLoad];
@@ -3048,7 +3048,7 @@ - (void)attemptToApplyCredentialsAndResume
// We've failed NTLM authentication twice, we should assume our credentials are wrong
} else if ([self authenticationScheme] == (NSString *)kCFHTTPAuthenticationSchemeNTLM && [self authenticationRetryCount ] == 2) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ has failed NTLM authentication",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ has failed NTLM authentication",self);
#endif
[self failWithError:ASIAuthenticationError];
@@ -3056,7 +3056,7 @@ - (void)attemptToApplyCredentialsAndResume
} else {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ had credentials and they were not marked as bad, but we got a 401 all the same.",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ had credentials and they were not marked as bad, but we got a 401 all the same.",self);
#endif
[self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIInternalErrorWhileApplyingCredentialsType userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"Failed to apply credentials to request",NSLocalizedDescriptionKey,nil]]];
@@ -3072,7 +3072,7 @@ - (void)attemptToApplyCredentialsAndResume
if ([self error] || [self isCancelled]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ failed or was cancelled while waiting to access credentials",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ failed or was cancelled while waiting to access credentials",self);
#endif
[delegateAuthenticationLock unlock];
@@ -3085,7 +3085,7 @@ - (void)attemptToApplyCredentialsAndResume
if (credentials && [self applyCredentials:[credentials objectForKey:@"Credentials"]]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will reuse cached credentials from the session (%@)",self,[credentials objectForKey:@"AuthenticationScheme"]);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will reuse cached credentials from the session (%@)",self,[credentials objectForKey:@"AuthenticationScheme"]);
#endif
[delegateAuthenticationLock unlock];
@@ -3105,7 +3105,7 @@ - (void)attemptToApplyCredentialsAndResume
[self startRequest];
} else {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ failed to apply credentials",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ failed to apply credentials",self);
#endif
[delegateAuthenticationLock unlock];
[self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIInternalErrorWhileApplyingCredentialsType userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"Failed to apply credentials to request",NSLocalizedDescriptionKey,nil]]];
@@ -3115,7 +3115,7 @@ - (void)attemptToApplyCredentialsAndResume
if ([self willAskDelegateForCredentials]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will ask its delegate for credentials to use",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will ask its delegate for credentials to use",self);
#endif
[delegateAuthenticationLock unlock];
@@ -3124,7 +3124,7 @@ - (void)attemptToApplyCredentialsAndResume
if ([self showAuthenticationDialog]) {
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ will ask ASIAuthenticationDialog for credentials",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ will ask ASIAuthenticationDialog for credentials",self);
#endif
[delegateAuthenticationLock unlock];
@@ -3132,7 +3132,7 @@ - (void)attemptToApplyCredentialsAndResume
}
#if DEBUG_HTTP_AUTHENTICATION
- NSLog(@"[AUTH] Request %@ has no credentials to present and must give up",self);
+ ASI_DEBUG_LOG(@"[AUTH] Request %@ has no credentials to present and must give up",self);
#endif
[delegateAuthenticationLock unlock];
[self failWithError:ASIAuthenticationError];
@@ -3373,7 +3373,7 @@ - (void)handleStreamComplete
{
#if DEBUG_REQUEST_STATUS
- NSLog(@"[STATUS] Request %@ finished downloading data (%qu bytes)",self, [self totalBytesRead]);
+ ASI_DEBUG_LOG(@"[STATUS] Request %@ finished downloading data (%qu bytes)",self, [self totalBytesRead]);
#endif
[self setStatusTimer:nil];
[self setDownloadComplete:YES];
@@ -3471,7 +3471,7 @@ - (void)handleStreamComplete
}
#if DEBUG_PERSISTENT_CONNECTIONS
if ([self requestID]) {
- NSLog(@"[CONNECTION] Request #%@ finished using connection #%@",[self requestID], [[self connectionInfo] objectForKey:@"id"]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Request #%@ finished using connection #%@",[self requestID], [[self connectionInfo] objectForKey:@"id"]);
}
#endif
[[self connectionInfo] removeObjectForKey:@"request"];
@@ -3612,7 +3612,7 @@ - (BOOL)retryUsingNewConnection
[self setWillRetryRequest:NO];
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Request attempted to use connection #%@, but it has been closed - will retry with a new connection", [[self connectionInfo] objectForKey:@"id"]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Request attempted to use connection #%@, but it has been closed - will retry with a new connection", [[self connectionInfo] objectForKey:@"id"]);
#endif
[connectionsLock lock];
[[self connectionInfo] removeObjectForKey:@"request"];
@@ -3624,7 +3624,7 @@ - (BOOL)retryUsingNewConnection
return YES;
}
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Request attempted to use connection #%@, but it has been closed - we have already retried with a new connection, so we must give up", [[self connectionInfo] objectForKey:@"id"]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Request attempted to use connection #%@, but it has been closed - we have already retried with a new connection, so we must give up", [[self connectionInfo] objectForKey:@"id"]);
#endif
return NO;
}
@@ -4012,7 +4012,7 @@ + (void)expirePersistentConnections
NSDictionary *existingConnection = [persistentConnectionsPool objectAtIndex:i];
if (![existingConnection objectForKey:@"request"] && [[existingConnection objectForKey:@"expires"] timeIntervalSinceNow] <= 0) {
#if DEBUG_PERSISTENT_CONNECTIONS
- NSLog(@"[CONNECTION] Closing connection #%i because it has expired",[[existingConnection objectForKey:@"id"] intValue]);
+ ASI_DEBUG_LOG(@"[CONNECTION] Closing connection #%i because it has expired",[[existingConnection objectForKey:@"id"] intValue]);
#endif
NSInputStream *stream = [existingConnection objectForKey:@"stream"];
if (stream) {
@@ -4468,14 +4468,14 @@ - (void)performThrottling
if ([self readStreamIsScheduled]) {
[self unscheduleReadStream];
#if DEBUG_THROTTLING
- NSLog(@"[THROTTLING] Sleeping request %@ until after %@",self,throttleWakeUpTime);
+ ASI_DEBUG_LOG(@"[THROTTLING] Sleeping request %@ until after %@",self,throttleWakeUpTime);
#endif
}
} else {
if (![self readStreamIsScheduled]) {
[self scheduleReadStream];
#if DEBUG_THROTTLING
- NSLog(@"[THROTTLING] Waking up request %@",self);
+ ASI_DEBUG_LOG(@"[THROTTLING] Waking up request %@",self);
#endif
}
}
@@ -4538,7 +4538,7 @@ + (void)recordBandwidthUsage
}
}
#if DEBUG_THROTTLING
- NSLog(@"[THROTTLING] ===Used: %u bytes of bandwidth in last measurement period===",bandwidthUsedInLastSecond);
+ ASI_DEBUG_LOG(@"[THROTTLING] ===Used: %u bytes of bandwidth in last measurement period===",bandwidthUsedInLastSecond);
#endif
[bandwidthUsageTracker addObject:[NSNumber numberWithUnsignedLong:bandwidthUsedInLastSecond]];
[bandwidthMeasurementDate release];
8 Classes/ASIHTTPRequestConfig.h
View
@@ -11,6 +11,12 @@
// Debug output configuration options
// ======
+// If defined will use the specified function for debug logging
+// Otherwise use NSLog
+#ifndef ASI_DEBUG_LOG
+ #define ASI_DEBUG_LOG NSLog
+#endif
+
// When set to 1 ASIHTTPRequests will print information about what a request is doing
#ifndef DEBUG_REQUEST_STATUS
#define DEBUG_REQUEST_STATUS 0
@@ -33,5 +39,5 @@
// When set to 1, ASIHTTPRequests will print information about HTTP authentication (Basic, Digest or NTLM) to the console
#ifndef DEBUG_HTTP_AUTHENTICATION
-#define DEBUG_HTTP_AUTHENTICATION 0
+ #define DEBUG_HTTP_AUTHENTICATION 0
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.