mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Minor cleanups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25175 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
50f974a365
commit
dd3bd664ac
3 changed files with 40 additions and 21 deletions
|
@ -1,3 +1,9 @@
|
|||
2007-05-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURLConnection.m: Cancel when deallocating.
|
||||
* Source/NSURLProtocol.m: Make sure load is stopped if an error
|
||||
occurs.
|
||||
|
||||
2007-05-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSException.m: Permit some recursion in handling uncaught
|
||||
|
|
|
@ -182,7 +182,7 @@ typedef struct {
|
|||
{
|
||||
if (this != 0)
|
||||
{
|
||||
RELEASE(this->_protocol);
|
||||
[self cancel];
|
||||
RELEASE(this->_request);
|
||||
NSZoneFree([self zone], this);
|
||||
_NSURLConnectionInternal = 0;
|
||||
|
|
|
@ -334,6 +334,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
if ([methods objectForKey: [this->request HTTPMethod]] == nil)
|
||||
{
|
||||
NSLog(@"Invalid HTTP Method: %@", this->request);
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError:
|
||||
[NSError errorWithDomain: @"Invalid HTTP Method"
|
||||
code: 0
|
||||
|
@ -380,6 +381,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
e = [NSError errorWithDomain: @"Invalid redirect request"
|
||||
code: 0
|
||||
userInfo: nil];
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self
|
||||
didFailWithError: e];
|
||||
}
|
||||
|
@ -431,6 +433,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
{
|
||||
NSLog(@"did not create streams for %@:%@", host, [url port]);
|
||||
}
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError:
|
||||
[NSError errorWithDomain: @"can't connect" code: 0 userInfo:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
|
@ -497,7 +500,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
{
|
||||
NSLog(@"receive error %@", e);
|
||||
}
|
||||
[self _unschedule];
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError: e];
|
||||
}
|
||||
return;
|
||||
|
@ -523,7 +526,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
e = [NSError errorWithDomain: @"parse error"
|
||||
code: 0
|
||||
userInfo: nil];
|
||||
[self _unschedule];
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError: e];
|
||||
return;
|
||||
}
|
||||
|
@ -612,6 +615,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
e = [NSError errorWithDomain: @"Invalid redirect request"
|
||||
code: 0
|
||||
userInfo: nil];
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self
|
||||
didFailWithError: e];
|
||||
}
|
||||
|
@ -747,26 +751,35 @@ static NSURLProtocol *placeholder = nil;
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Tell superclass that we have successfully loaded the data.
|
||||
* Tell superclass that we have successfully loaded the data
|
||||
* (as long as we haven't had the load terminated by the client).
|
||||
*/
|
||||
d = [_parser data];
|
||||
bodyLength = [d length];
|
||||
if (bodyLength > _parseOffset)
|
||||
if (_isLoading == YES)
|
||||
{
|
||||
if (_parseOffset > 0)
|
||||
{
|
||||
d = [d subdataWithRange:
|
||||
NSMakeRange(_parseOffset, bodyLength - _parseOffset)];
|
||||
}
|
||||
_parseOffset = bodyLength;
|
||||
if (_isLoading == YES)
|
||||
d = [_parser data];
|
||||
bodyLength = [d length];
|
||||
if (bodyLength > _parseOffset)
|
||||
{
|
||||
if (_parseOffset > 0)
|
||||
{
|
||||
d = [d subdataWithRange:
|
||||
NSMakeRange(_parseOffset, bodyLength - _parseOffset)];
|
||||
}
|
||||
_parseOffset = bodyLength;
|
||||
[this->client URLProtocol: self didLoadData: d];
|
||||
}
|
||||
|
||||
/* Check again in case the client cancelled the load inside
|
||||
* the URLProtocol:didLoadData: callback.
|
||||
*/
|
||||
if (_isLoading == YES)
|
||||
{
|
||||
_isLoading = NO;
|
||||
[this->client URLProtocolDidFinishLoading: self];
|
||||
}
|
||||
}
|
||||
[this->client URLProtocolDidFinishLoading: self];
|
||||
}
|
||||
else
|
||||
else if (_isLoading == YES)
|
||||
{
|
||||
/*
|
||||
* Report partial data if possible.
|
||||
|
@ -783,15 +796,12 @@ static NSURLProtocol *placeholder = nil;
|
|||
NSMakeRange(_parseOffset, [d length] - _parseOffset)];
|
||||
}
|
||||
_parseOffset = bodyLength;
|
||||
if (_isLoading == YES)
|
||||
{
|
||||
[this->client URLProtocol: self didLoadData: d];
|
||||
}
|
||||
[this->client URLProtocol: self didLoadData: d];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_complete == NO && readCount == 0)
|
||||
if (_complete == NO && readCount == 0 && _isLoading == YES)
|
||||
{
|
||||
/* The read failed ... dropped, but parsing is not complete.
|
||||
* The request was sent, so we can't know whether it was
|
||||
|
@ -802,6 +812,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
{
|
||||
NSLog(@"HTTP response not received - %@", _parser);
|
||||
}
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError:
|
||||
[NSError errorWithDomain: @"receive incomplete"
|
||||
code: 0
|
||||
|
@ -986,6 +997,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
NSLog(@"error reading from HTTPBody stream %@",
|
||||
[NSError _last]);
|
||||
}
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError:
|
||||
[NSError errorWithDomain: @"can't read body"
|
||||
code: 0
|
||||
|
@ -1050,6 +1062,7 @@ static NSURLProtocol *placeholder = nil;
|
|||
}
|
||||
}
|
||||
NSLog(@"An error %@ occurred on the event %08x of stream %@ of %@", [stream streamError], event, stream, self);
|
||||
[self stopLoading];
|
||||
[this->client URLProtocol: self didFailWithError: [stream streamError]];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue