diff --git a/ASIFormDataRequestTests.m b/ASIFormDataRequestTests.m index a11b8aa0..bdb73f45 100644 --- a/ASIFormDataRequestTests.m +++ b/ASIFormDataRequestTests.m @@ -22,7 +22,7 @@ - (void)testPostWithFileUpload NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"bigfile"]; [data writeToFile:path atomically:NO]; - ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://asi/asi-http-request/tests/post"]] autorelease]; + ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http:/http://allseeing-i.com/asi-http-request/tests/post"]] autorelease]; [request setPostValue:@"foo" forKey:@"post_var"]; [request setFile:path forKey:@"file"]; [request start]; diff --git a/ASIHTTPRequest.m b/ASIHTTPRequest.m index f64c464b..f1d4aec9 100644 --- a/ASIHTTPRequest.m +++ b/ASIHTTPRequest.m @@ -62,7 +62,6 @@ - (id)initWithURL:(NSURL *)newURL outputStream = nil; requestAuthentication = NULL; haveBuiltPostBody = NO; - //credentials = NULL; request = NULL; responseHeaders = nil; [self setTimeOutSeconds:10]; @@ -226,10 +225,6 @@ - (void)main CFHTTPMessageSetHeaderFieldValue(request, (CFStringRef)header, (CFStringRef)[requestHeaders objectForKey:header]); } - //NSData *d = (NSData *)CFHTTPMessageCopySerializedMessage(request); - //NSLog(@"%@",[[[NSString alloc] initWithBytes:[d bytes] length:[d length] encoding:NSUTF8StringEncoding] autorelease]); - - // If this is a post request and we have data to send, add it to the request if ([self postBody]) { CFHTTPMessageSetBody(request, (CFDataRef)postBody); @@ -388,7 +383,6 @@ - (void)cancelLoad - (void)updateProgressIndicators { - //Only update progress if this isn't a HEAD request used to preset the content-length if (!mainRequest) { if (showAccurateProgress || (complete && !updatedProgress)) { @@ -396,7 +390,6 @@ - (void)updateProgressIndicators [self updateDownloadProgress]; } } - } @@ -519,7 +512,7 @@ - (void)updateDownloadProgress { unsigned long long bytesReadSoFar = totalBytesRead; - //We won't update download progress until we've examined the headers, since we might need to authenticate + // We won't update download progress until we've examined the headers, since we might need to authenticate if (responseHeaders) { if (bytesReadSoFar > lastBytesRead) { @@ -528,8 +521,7 @@ - (void)updateDownloadProgress if (downloadProgressDelegate) { - - //We're using a progress queue or compatible controller to handle progress + // We're using a progress queue or compatible controller to handle progress if ([downloadProgressDelegate respondsToSelector:@selector(incrementDownloadProgressBy:)]) { NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init]; @@ -554,7 +546,7 @@ - (void)updateDownloadProgress [thePool release]; - //We aren't using a queue, we should just set progress of the indicator to 0 + // We aren't using a queue, we should just set progress of the indicator to 0 } else if (contentLength > 0) { [ASIHTTPRequest setProgress:(double)(bytesReadSoFar/contentLength) forProgressIndicator:downloadProgressDelegate]; } @@ -568,7 +560,7 @@ - (void)updateDownloadProgress -(void)removeUploadProgressSoFar { - //We're using a progress queue or compatible controller to handle progress + // We're using a progress queue or compatible controller to handle progress if ([uploadProgressDelegate respondsToSelector:@selector(decrementUploadProgressBy:)]) { unsigned long long value = 0-lastBytesSent; SEL selector = @selector(decrementUploadProgressBy:); @@ -579,7 +571,7 @@ -(void)removeUploadProgressSoFar [invocation setArgument:&value atIndex:2]; [invocation invoke]; - //We aren't using a queue, we should just set progress of the indicator to 0 + // We aren't using a queue, we should just set progress of the indicator to 0 } else { [ASIHTTPRequest setProgress:0 forProgressIndicator:uploadProgressDelegate]; } @@ -598,11 +590,11 @@ + (void)setProgress:(double)progress forProgressIndicator:(id)indicator NSMethodSignature *signature = [[indicator class] instanceMethodSignatureForSelector:selector]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; [invocation setSelector:selector]; - float progressFloat = (float)progress; //UIProgressView wants a float for the progress parameter + float progressFloat = (float)progress; // UIProgressView wants a float for the progress parameter [invocation setArgument:&progressFloat atIndex:2]; [invocation invokeWithTarget:indicator]; - //If we're running in the main thread, update the progress straight away. Otherwise, it's not that urgent + // If we're running in the main thread, update the progress straight away. Otherwise, it's not that urgent [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:indicator waitUntilDone:[NSThread isMainThread]]; @@ -667,10 +659,10 @@ - (BOOL)readResponseHeadersReturningAuthenticationFailure // Is the server response a challenge for credentials? isAuthenticationChallenge = (responseStatusCode == 401); - //We won't reset the download progress delegate if we got an authentication challenge + // We won't reset the download progress delegate if we got an authentication challenge if (!isAuthenticationChallenge) { - //See if we got a Content-length header + // See if we got a Content-length header NSString *cLength = [responseHeaders valueForKey:@"Content-Length"]; if (cLength) { contentLength = CFStringGetIntValue((CFStringRef)cLength); @@ -682,15 +674,16 @@ - (BOOL)readResponseHeadersReturningAuthenticationFailure } } - //Handle cookies + // Handle cookies NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:responseHeaders forURL:url]; [self setResponseCookies:cookies]; if (useCookiePersistance) { - //Store cookies in global persistent store + + // Store cookies in global persistent store [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookies:cookies forURL:url mainDocumentURL:nil]; - //We also keep any cookies in the sessionCookies array, so that we have a reference to them if we need to remove them later + // We also keep any cookies in the sessionCookies array, so that we have a reference to them if we need to remove them later if (!sessionCookies) { [ASIHTTPRequest setSessionCookies:[[[NSMutableArray alloc] init] autorelease]]; NSHTTPCookie *cookie; @@ -711,7 +704,8 @@ - (BOOL)readResponseHeadersReturningAuthenticationFailure - (void)saveCredentialsToKeychain:(NSMutableDictionary *)newCredentials { NSURLCredential *authenticationCredentials = [NSURLCredential credentialWithUser:[newCredentials objectForKey:(NSString *)kCFHTTPAuthenticationUsername] - password:[newCredentials objectForKey:(NSString *)kCFHTTPAuthenticationPassword] persistence:NSURLCredentialPersistencePermanent]; + password:[newCredentials objectForKey:(NSString *)kCFHTTPAuthenticationPassword] + persistence:NSURLCredentialPersistencePermanent]; if (authenticationCredentials) { [ASIHTTPRequest saveCredentials:authenticationCredentials forHost:[url host] port:[[url port] intValue] protocol:[url scheme] realm:authenticationRealm]; @@ -958,8 +952,6 @@ - (void)handleBytesAvailable - (void)handleStreamComplete { - - //Try to read the headers (if this is a HEAD request handleBytesAvailable available may not be called) if (!responseHeaders) { if ([self readResponseHeadersReturningAuthenticationFailure]) { diff --git a/ASINetworkQueueTests.m b/ASINetworkQueueTests.m index 8532e9f6..db46772f 100644 --- a/ASINetworkQueueTests.m +++ b/ASINetworkQueueTests.m @@ -205,7 +205,6 @@ - (void)queueFinished:(ASINetworkQueue *)queue { complete = YES; } -