mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-07 19:27:12 +00:00
Fix for CPDocument not opening with file local URLs.
Reviewed by me.
This commit is contained in:
+5
-1
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user