Skip to content

Commit

Permalink
Fix for local CPURLConnection requests (file:///)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Boucher committed Nov 11, 2008
1 parent 937865e commit add1776
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Foundation/CPURLConnection.j
Expand Up @@ -222,14 +222,15 @@ var CPURLConnectionDelegate = nil;
{
if (_XMLHTTPRequest.readyState == XMLHTTPRequestComplete)
{
var statusCode = _XMLHTTPRequest.status;
var statusCode = _XMLHTTPRequest.status,
url = [_request URL];

if ([_delegate respondsToSelector:@selector(connection:didReceiveResponse:)])
[_delegate connection:self didReceiveResponse:[[CPHTTPURLResponse alloc] _initWithStatusCode:statusCode]];

if (!_isCanceled)
{
if (statusCode == 200)
if (statusCode == 200 || (url.indexOf("file:") === 0 && statusCode === 0) || ((url.indexOf("http:") !== 0 || url.indexOf("https:") !== 0) && window.location && window.location.protocol === "file:" && statusCode === 0))
{
[_delegate connection:self didReceiveData:_XMLHTTPRequest.responseText];
[_delegate connectionDidFinishLoading:self];
Expand Down

0 comments on commit add1776

Please sign in to comment.