diff --git a/AppKit/CPDocument.j b/AppKit/CPDocument.j index cc3c8f87c..3282ba261 100644 --- a/AppKit/CPDocument.j +++ b/AppKit/CPDocument.j @@ -386,10 +386,14 @@ var CPDocumentUntitledCount = 0; */ - (void)connection:(CPURLConnection)aConnection didReceiveResponse:(CPURLResponse)aResponse { + // If we got this far and it wasn't an HTTP request, then everything is fine. + if (![aResponse isKindOfClass:[CPHTTPURLResponse class]]) + return; + var statusCode = [aResponse statusCode]; // Nothing to do if everything is hunky dory. - if (statusCode === 200 || (statusCode === 0 && [aConnection isLocalFileConnection])) + if (statusCode === 200) return; var session = aConnection.session; diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index a8424bed1..8248cd191 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -235,11 +235,20 @@ var CPURLConnectionDelegate = nil; if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete) { var statusCode = _XMLHTTPRequest.status, - url = [_request URL]; + URL = [_request URL]; if ([_delegate respondsToSelector:@selector(connection:didReceiveResponse:)]) - [_delegate connection:self didReceiveResponse:[[CPHTTPURLResponse alloc] _initWithStatusCode:statusCode]]; - + if (_isLocalFileConnection) + [_delegate connection:self didReceiveResponse:[[CPURLResponse alloc] initWithURL:URL]]; + else + { + var response = [[CPHTTPURLResponse alloc] initWithURL:URL]; + + [response _setStatusCode:statusCode]; + + [_delegate connection:self didReceiveResponse:response]; + } + if (!_isCanceled) { if (statusCode == 200 || (statusCode === 0 && _isLocalFileConnection)) diff --git a/Foundation/CPURLResponse.j b/Foundation/CPURLResponse.j index 0f4a9cfa4..1287a0c15 100644 --- a/Foundation/CPURLResponse.j +++ b/Foundation/CPURLResponse.j @@ -34,6 +34,22 @@ */ @implementation CPURLResponse : CPObject { + CPURL _URL; +} + +- (id)initWithURL:(CPURL)aURL +{ + self = [super init]; + + if (self) + _URL = aURL; + + return self; +} + +- (CPURL)URL +{ + return _URL; } /* Creating a Response @@ -56,14 +72,9 @@ Getting the Response Properties } /* @ignore */ -- (id)_initWithStatusCode:(int)aStatusCode +- (id)_setStatusCode:(int)aStatusCode { - self = [super init]; - - if (self) - _statusCode = aStatusCode; - - return self; + _statusCode = aStatusCode; } /*!