Permalink
Browse files

work progressing on trying to get it to compile for windows, cfauth n…

…eeds to be rewritten i think, ive set this as a low priority to be looked at in the future after mac release.
  • Loading branch information...
pellet committed May 25, 2011
1 parent f8cf9f7 commit cf1bebbf7a75e42bee334640ee2f27fe6ebd8eae
Showing with 21 additions and 9 deletions.
  1. +3 −2 Classes/ASIHTTPRequest.h
  2. +18 −7 Classes/ASIHTTPRequest.m
View
@@ -25,6 +25,7 @@
#import "Foundation/NSURLCredential.h"
#import "Security/Security.h"
#import <CFNetwork/CFNetwork.h>
+ #import "CFNetworkWrapper.h"
#endif
//@@@
@@ -203,7 +204,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
NSInputStream *readStream;
// Used for authentication
- CFHTTPAuthenticationRef requestAuthentication;
+ CFHTTPAuthenticationRef requestAuthentication;
NSDictionary *requestCredentials;
// Used during NTLM authentication
@@ -226,7 +227,7 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount;
BOOL shouldPresentProxyAuthenticationDialog;
// Used for proxy authentication
- CFHTTPAuthenticationRef proxyAuthentication;
+ CFHTTPAuthenticationRef proxyAuthentication;
NSDictionary *proxyCredentials;
// Used during authentication with an NTLM proxy
View
@@ -12,11 +12,7 @@
#import "ASIHTTPRequest.h"
-#ifndef BP_COCOTRON
- #import <zlib.h>
-#else
- #import <Onyx2D/O2zlib.h>
-#endif
+#import <zlib.h>
#if TARGET_OS_IPHONE
#import "Reachability.h"
@@ -26,6 +22,8 @@
//@@@BPHACK NOTE: Why is this used?
#ifndef BP_COCOTRON
#import <SystemConfiguration/SystemConfiguration.h>
+#else
+#import "CFSSLHandler_openssl.h"
#endif
//@@@
#endif
@@ -320,12 +318,14 @@ + (id)requestWithURL:(NSURL *)newURL usingCache:(id <ASICacheDelegate>)cache and
- (void)dealloc
{
[self setAuthenticationNeeded:ASINoAuthenticationNeededYet];
+#ifndef BP_COCOTRON
if (requestAuthentication) {
CFRelease(requestAuthentication);
}
if (proxyAuthentication) {
CFRelease(proxyAuthentication);
}
+#endif
if (request) {
CFRelease(request);
}
@@ -775,12 +775,12 @@ - (void)applyAuthorizationHeader
}
}
+#ifndef BP_COCOTRON
if (credentials && ![[self requestHeaders] objectForKey:@"Authorization"]) {
// When the Authentication key is set, the credentials were stored after an authentication challenge, so we can let CFNetwork apply them
// (credentials for Digest and NTLM will always be stored like this)
if ([credentials objectForKey:@"Authentication"]) {
-
// If we've already talked to this server and have valid credentials, let's apply them to the request
if (!CFHTTPMessageApplyCredentialDictionary(request, (CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) {
[[self class] removeAuthenticationCredentialsFromSessionStore:[credentials objectForKey:@"Credentials"]];
@@ -793,14 +793,22 @@ - (void)applyAuthorizationHeader
[self addBasicAuthenticationHeaderWithUsername:[usernameAndPassword objectForKey:(NSString *)kCFHTTPAuthenticationUsername] andPassword:[usernameAndPassword objectForKey:(NSString *)kCFHTTPAuthenticationPassword]];
}
}
+#else
+ assert(!credentials);
+#endif
if ([self useSessionPersistence]) {
credentials = [self findSessionProxyAuthenticationCredentials];
if (credentials) {
+#ifndef BP_COCOTRON
if (!CFHTTPMessageApplyCredentialDictionary(request, (CFHTTPAuthenticationRef)[credentials objectForKey:@"Authentication"], (CFDictionaryRef)[credentials objectForKey:@"Credentials"], NULL)) {
[[self class] removeProxyAuthenticationCredentialsFromSessionStore:[credentials objectForKey:@"Credentials"]];
}
+#else
+ assert(!credentials);
+#endif
}
}
+
}
- (void)applyCookieHeader
@@ -1166,7 +1174,9 @@ - (void)startRequest
}
[[self connectionInfo] setObject:[self requestID] forKey:@"request"];
[[self connectionInfo] setObject:[self readStream] forKey:@"stream"];
+#ifndef BP_COCOTRON
CFReadStreamSetProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPAttemptPersistentConnection, kCFBooleanTrue);
+#endif
#if DEBUG_PERSISTENT_CONNECTIONS
NSLog(@"Request #%@ will use connection #%i",[self requestID],[[[self connectionInfo] objectForKey:@"id"] intValue]);
@@ -1342,7 +1352,9 @@ - (void)checkRequestStatus
// Find out how much data we've uploaded so far
//@@@BPHACK/Fix more casting fixes...
+#ifndef BP_COCOTRON
[self setTotalBytesSent:[(id)NSMakeCollectable([(NSNumber *)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPRequestBytesWrittenCount) autorelease]) unsignedLongLongValue]];
+#endif
//@@@
if (totalBytesSent > lastBytesSent) {
@@ -1846,7 +1858,6 @@ - (void)failWithError:(NSError *)theError
- (void)readResponseHeaders
{
[self setAuthenticationNeeded:ASINoAuthenticationNeededYet];
-
CFHTTPMessageRef message = (CFHTTPMessageRef)CFReadStreamCopyProperty((CFReadStreamRef)[self readStream], kCFStreamPropertyHTTPResponseHeader);
if (!message) {
return;

0 comments on commit cf1bebb

Please sign in to comment.