diff --git a/ChangeLog b/ChangeLog index 0d5783d36..b58915c0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ 2009-01-30 Richard Frith-Macdonald * Source/NSURL.m: For file URL, make relative path absolute. + * Source/GSHTTPURLHandle.m: + * Source/Additions/GSMime.m: + Change HTTP status code to be an NSNumber rather than NSString + for MacOS-X compatibility 2009-01-30 Richard Frith-Macdonald diff --git a/Source/Additions/GSMime.m b/Source/Additions/GSMime.m index 1b1a860de..7a6231038 100644 --- a/Source/Additions/GSMime.m +++ b/Source/Additions/GSMime.m @@ -1524,12 +1524,12 @@ wordData(NSString *word) info = [[document headersNamed: @"http"] lastObject]; if (info != nil && flags.isHttp == 1) { - NSString *val; + NSNumber *num; - val = [info objectForKey: NSHTTPPropertyStatusCodeKey]; - if (val != nil) + num = [info objectForKey: NSHTTPPropertyStatusCodeKey]; + if (num != nil) { - int v = [val intValue]; + int v = [num intValue]; if (v >= 100 && v < 200) { @@ -1612,7 +1612,7 @@ wordData(NSString *word) * NSHTTPPropertyServerHTTPVersionKey * The full HTTP protocol version number * NSHTTPPropertyStatusCodeKey - * The HTTP status code + * The HTTP status code (numeric) * NSHTTPPropertyStatusReasonKey * The text message (if any) after the status code * @@ -1881,7 +1881,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info); forKey: @"HttpVersion"]; [info setObject: [NSStringClass stringWithFormat: @"%d", major] forKey: NSHTTPPropertyServerHTTPVersionKey]; - [info setObject: [NSStringClass stringWithFormat: @"%d", status] + [info setObject: [NSNumber numberWithInt: status] forKey: NSHTTPPropertyStatusCodeKey]; [self scanPastSpace: scanner]; value = [[scanner string] substringFromIndex: [scanner scanLocation]]; diff --git a/Source/GSHTTPURLHandle.m b/Source/GSHTTPURLHandle.m index e0b95e520..c194c9b15 100644 --- a/Source/GSHTTPURLHandle.m +++ b/Source/GSHTTPURLHandle.m @@ -593,12 +593,12 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) GSMimeHeader *info; NSString *enc; NSString *len; - NSString *status; + int status; float ver; info = [document headerNamed: @"http"]; ver = [[info value] floatValue]; - status = [info objectForKey: NSHTTPPropertyStatusCodeKey]; + status = [[info objectForKey: NSHTTPPropertyStatusCodeKey] intValue]; len = [[document headerNamed: @"content-length"] value]; enc = [[document headerNamed: @"content-transfer-encoding"] value]; if (enc == nil) @@ -606,7 +606,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) enc = [[document headerNamed: @"transfer-encoding"] value]; } - if ([status isEqual: @"204"] || [status isEqual: @"304"]) + if (status == 204 || status == 304) { complete = YES; // No body expected. } @@ -623,6 +623,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) { GSMimeHeader *info; NSString *val; + NSNumber *num; float ver; int code; @@ -642,8 +643,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) * Retrieve essential keys from document */ info = [document headerNamed: @"http"]; - val = [info objectForKey: NSHTTPPropertyStatusCodeKey]; - code = [val intValue]; + num = [info objectForKey: NSHTTPPropertyStatusCodeKey]; + code = [num intValue]; if (code == 401 && self->challenged < 2) { GSMimeHeader *ah; @@ -720,9 +721,9 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) } } } - if (val != nil) + if (num != nil) { - [pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey]; + [pageInfo setObject: num forKey: NSHTTPPropertyStatusCodeKey]; } val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey]; if (val != nil) @@ -818,15 +819,16 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) { GSMimeHeader *info; NSString *val; + NSNumber *num; [p parse: nil]; info = [[p mimeDocument] headerNamed: @"http"]; val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey]; if (val != nil) [pageInfo setObject: val forKey: NSHTTPPropertyServerHTTPVersionKey]; - val = [info objectForKey: NSHTTPPropertyStatusCodeKey]; - if (val != nil) - [pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey]; + num = [info objectForKey: NSHTTPPropertyStatusCodeKey]; + if (num != nil) + [pageInfo setObject: num forKey: NSHTTPPropertyStatusCodeKey]; val = [info objectForKey: NSHTTPPropertyStatusReasonKey]; if (val != nil) [pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey]; @@ -926,7 +928,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) NSTimeInterval limit = 0.01; NSData *buf; NSDate *when; - NSString *status; + int status; NSString *version; version = [request objectForKey: NSHTTPPropertyServerHTTPVersionKey]; @@ -949,7 +951,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) * Set up default status for if connection is lost. */ [pageInfo setObject: @"1.0" forKey: NSHTTPPropertyServerHTTPVersionKey]; - [pageInfo setObject: @"503" forKey: NSHTTPPropertyStatusCodeKey]; + [pageInfo setObject: [NSNumber numberWithInt: 503] + forKey: NSHTTPPropertyStatusCodeKey]; [pageInfo setObject: @"Connection dropped by proxy server" forKey: NSHTTPPropertyStatusReasonKey]; @@ -978,8 +981,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data) } RELEASE(when); - status = [pageInfo objectForKey: NSHTTPPropertyStatusCodeKey]; - if ([status isEqual: @"200"] == NO) + status = [[pageInfo objectForKey: NSHTTPPropertyStatusCodeKey] intValue]; + if (status != 200) { [self endLoadInBackground]; [self backgroundLoadDidFailWithReason: @"Failed proxy tunneling"];