Macos compatibility tweak

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27739 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-01-30 20:33:14 +00:00
parent 25b8816b4d
commit cbcc2fe893
3 changed files with 27 additions and 20 deletions

View file

@ -1,6 +1,10 @@
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org> 2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSURL.m: For file URL, make relative path absolute. * 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 <rfm@gnu.org> 2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -1524,12 +1524,12 @@ wordData(NSString *word)
info = [[document headersNamed: @"http"] lastObject]; info = [[document headersNamed: @"http"] lastObject];
if (info != nil && flags.isHttp == 1) if (info != nil && flags.isHttp == 1)
{ {
NSString *val; NSNumber *num;
val = [info objectForKey: NSHTTPPropertyStatusCodeKey]; num = [info objectForKey: NSHTTPPropertyStatusCodeKey];
if (val != nil) if (num != nil)
{ {
int v = [val intValue]; int v = [num intValue];
if (v >= 100 && v < 200) if (v >= 100 && v < 200)
{ {
@ -1612,7 +1612,7 @@ wordData(NSString *word)
* <term>NSHTTPPropertyServerHTTPVersionKey</term> * <term>NSHTTPPropertyServerHTTPVersionKey</term>
* <desc>The full HTTP protocol version number</desc> * <desc>The full HTTP protocol version number</desc>
* <term>NSHTTPPropertyStatusCodeKey</term> * <term>NSHTTPPropertyStatusCodeKey</term>
* <desc>The HTTP status code</desc> * <desc>The HTTP status code (numeric)</desc>
* <term>NSHTTPPropertyStatusReasonKey</term> * <term>NSHTTPPropertyStatusReasonKey</term>
* <desc>The text message (if any) after the status code</desc> * <desc>The text message (if any) after the status code</desc>
* </deflist> * </deflist>
@ -1881,7 +1881,7 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
forKey: @"HttpVersion"]; forKey: @"HttpVersion"];
[info setObject: [NSStringClass stringWithFormat: @"%d", major] [info setObject: [NSStringClass stringWithFormat: @"%d", major]
forKey: NSHTTPPropertyServerHTTPVersionKey]; forKey: NSHTTPPropertyServerHTTPVersionKey];
[info setObject: [NSStringClass stringWithFormat: @"%d", status] [info setObject: [NSNumber numberWithInt: status]
forKey: NSHTTPPropertyStatusCodeKey]; forKey: NSHTTPPropertyStatusCodeKey];
[self scanPastSpace: scanner]; [self scanPastSpace: scanner];
value = [[scanner string] substringFromIndex: [scanner scanLocation]]; value = [[scanner string] substringFromIndex: [scanner scanLocation]];

View file

@ -593,12 +593,12 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
GSMimeHeader *info; GSMimeHeader *info;
NSString *enc; NSString *enc;
NSString *len; NSString *len;
NSString *status; int status;
float ver; float ver;
info = [document headerNamed: @"http"]; info = [document headerNamed: @"http"];
ver = [[info value] floatValue]; ver = [[info value] floatValue];
status = [info objectForKey: NSHTTPPropertyStatusCodeKey]; status = [[info objectForKey: NSHTTPPropertyStatusCodeKey] intValue];
len = [[document headerNamed: @"content-length"] value]; len = [[document headerNamed: @"content-length"] value];
enc = [[document headerNamed: @"content-transfer-encoding"] value]; enc = [[document headerNamed: @"content-transfer-encoding"] value];
if (enc == nil) if (enc == nil)
@ -606,7 +606,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
enc = [[document headerNamed: @"transfer-encoding"] value]; enc = [[document headerNamed: @"transfer-encoding"] value];
} }
if ([status isEqual: @"204"] || [status isEqual: @"304"]) if (status == 204 || status == 304)
{ {
complete = YES; // No body expected. complete = YES; // No body expected.
} }
@ -623,6 +623,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
{ {
GSMimeHeader *info; GSMimeHeader *info;
NSString *val; NSString *val;
NSNumber *num;
float ver; float ver;
int code; int code;
@ -642,8 +643,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
* Retrieve essential keys from document * Retrieve essential keys from document
*/ */
info = [document headerNamed: @"http"]; info = [document headerNamed: @"http"];
val = [info objectForKey: NSHTTPPropertyStatusCodeKey]; num = [info objectForKey: NSHTTPPropertyStatusCodeKey];
code = [val intValue]; code = [num intValue];
if (code == 401 && self->challenged < 2) if (code == 401 && self->challenged < 2)
{ {
GSMimeHeader *ah; 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]; val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey];
if (val != nil) if (val != nil)
@ -818,15 +819,16 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
{ {
GSMimeHeader *info; GSMimeHeader *info;
NSString *val; NSString *val;
NSNumber *num;
[p parse: nil]; [p parse: nil];
info = [[p mimeDocument] headerNamed: @"http"]; info = [[p mimeDocument] headerNamed: @"http"];
val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey]; val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey];
if (val != nil) if (val != nil)
[pageInfo setObject: val forKey: NSHTTPPropertyServerHTTPVersionKey]; [pageInfo setObject: val forKey: NSHTTPPropertyServerHTTPVersionKey];
val = [info objectForKey: NSHTTPPropertyStatusCodeKey]; num = [info objectForKey: NSHTTPPropertyStatusCodeKey];
if (val != nil) if (num != nil)
[pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey]; [pageInfo setObject: num forKey: NSHTTPPropertyStatusCodeKey];
val = [info objectForKey: NSHTTPPropertyStatusReasonKey]; val = [info objectForKey: NSHTTPPropertyStatusReasonKey];
if (val != nil) if (val != nil)
[pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey]; [pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey];
@ -926,7 +928,7 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
NSTimeInterval limit = 0.01; NSTimeInterval limit = 0.01;
NSData *buf; NSData *buf;
NSDate *when; NSDate *when;
NSString *status; int status;
NSString *version; NSString *version;
version = [request objectForKey: NSHTTPPropertyServerHTTPVersionKey]; version = [request objectForKey: NSHTTPPropertyServerHTTPVersionKey];
@ -949,7 +951,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
* Set up default status for if connection is lost. * Set up default status for if connection is lost.
*/ */
[pageInfo setObject: @"1.0" forKey: NSHTTPPropertyServerHTTPVersionKey]; [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" [pageInfo setObject: @"Connection dropped by proxy server"
forKey: NSHTTPPropertyStatusReasonKey]; forKey: NSHTTPPropertyStatusReasonKey];
@ -978,8 +981,8 @@ static void debugWrite(GSHTTPURLHandle *handle, NSData *data)
} }
RELEASE(when); RELEASE(when);
status = [pageInfo objectForKey: NSHTTPPropertyStatusCodeKey]; status = [[pageInfo objectForKey: NSHTTPPropertyStatusCodeKey] intValue];
if ([status isEqual: @"200"] == NO) if (status != 200)
{ {
[self endLoadInBackground]; [self endLoadInBackground];
[self backgroundLoadDidFailWithReason: @"Failed proxy tunneling"]; [self backgroundLoadDidFailWithReason: @"Failed proxy tunneling"];