mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +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
8be79bf977
commit
3633b11e59
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>
|
2007-05-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSException.m: Permit some recursion in handling uncaught
|
* Source/NSException.m: Permit some recursion in handling uncaught
|
||||||
|
|
|
@ -182,7 +182,7 @@ typedef struct {
|
||||||
{
|
{
|
||||||
if (this != 0)
|
if (this != 0)
|
||||||
{
|
{
|
||||||
RELEASE(this->_protocol);
|
[self cancel];
|
||||||
RELEASE(this->_request);
|
RELEASE(this->_request);
|
||||||
NSZoneFree([self zone], this);
|
NSZoneFree([self zone], this);
|
||||||
_NSURLConnectionInternal = 0;
|
_NSURLConnectionInternal = 0;
|
||||||
|
|
|
@ -334,6 +334,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
if ([methods objectForKey: [this->request HTTPMethod]] == nil)
|
if ([methods objectForKey: [this->request HTTPMethod]] == nil)
|
||||||
{
|
{
|
||||||
NSLog(@"Invalid HTTP Method: %@", this->request);
|
NSLog(@"Invalid HTTP Method: %@", this->request);
|
||||||
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self didFailWithError:
|
[this->client URLProtocol: self didFailWithError:
|
||||||
[NSError errorWithDomain: @"Invalid HTTP Method"
|
[NSError errorWithDomain: @"Invalid HTTP Method"
|
||||||
code: 0
|
code: 0
|
||||||
|
@ -380,6 +381,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
e = [NSError errorWithDomain: @"Invalid redirect request"
|
e = [NSError errorWithDomain: @"Invalid redirect request"
|
||||||
code: 0
|
code: 0
|
||||||
userInfo: nil];
|
userInfo: nil];
|
||||||
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self
|
[this->client URLProtocol: self
|
||||||
didFailWithError: e];
|
didFailWithError: e];
|
||||||
}
|
}
|
||||||
|
@ -431,6 +433,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
{
|
{
|
||||||
NSLog(@"did not create streams for %@:%@", host, [url port]);
|
NSLog(@"did not create streams for %@:%@", host, [url port]);
|
||||||
}
|
}
|
||||||
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self didFailWithError:
|
[this->client URLProtocol: self didFailWithError:
|
||||||
[NSError errorWithDomain: @"can't connect" code: 0 userInfo:
|
[NSError errorWithDomain: @"can't connect" code: 0 userInfo:
|
||||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@ -497,7 +500,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
{
|
{
|
||||||
NSLog(@"receive error %@", e);
|
NSLog(@"receive error %@", e);
|
||||||
}
|
}
|
||||||
[self _unschedule];
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self didFailWithError: e];
|
[this->client URLProtocol: self didFailWithError: e];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -523,7 +526,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
e = [NSError errorWithDomain: @"parse error"
|
e = [NSError errorWithDomain: @"parse error"
|
||||||
code: 0
|
code: 0
|
||||||
userInfo: nil];
|
userInfo: nil];
|
||||||
[self _unschedule];
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self didFailWithError: e];
|
[this->client URLProtocol: self didFailWithError: e];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -612,6 +615,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
e = [NSError errorWithDomain: @"Invalid redirect request"
|
e = [NSError errorWithDomain: @"Invalid redirect request"
|
||||||
code: 0
|
code: 0
|
||||||
userInfo: nil];
|
userInfo: nil];
|
||||||
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self
|
[this->client URLProtocol: self
|
||||||
didFailWithError: e];
|
didFailWithError: e];
|
||||||
}
|
}
|
||||||
|
@ -747,26 +751,35 @@ static NSURLProtocol *placeholder = nil;
|
||||||
#endif
|
#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];
|
if (_isLoading == YES)
|
||||||
bodyLength = [d length];
|
|
||||||
if (bodyLength > _parseOffset)
|
|
||||||
{
|
{
|
||||||
if (_parseOffset > 0)
|
d = [_parser data];
|
||||||
{
|
bodyLength = [d length];
|
||||||
d = [d subdataWithRange:
|
if (bodyLength > _parseOffset)
|
||||||
NSMakeRange(_parseOffset, bodyLength - _parseOffset)];
|
|
||||||
}
|
|
||||||
_parseOffset = bodyLength;
|
|
||||||
if (_isLoading == YES)
|
|
||||||
{
|
{
|
||||||
|
if (_parseOffset > 0)
|
||||||
|
{
|
||||||
|
d = [d subdataWithRange:
|
||||||
|
NSMakeRange(_parseOffset, bodyLength - _parseOffset)];
|
||||||
|
}
|
||||||
|
_parseOffset = bodyLength;
|
||||||
[this->client URLProtocol: self didLoadData: d];
|
[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.
|
* Report partial data if possible.
|
||||||
|
@ -783,15 +796,12 @@ static NSURLProtocol *placeholder = nil;
|
||||||
NSMakeRange(_parseOffset, [d length] - _parseOffset)];
|
NSMakeRange(_parseOffset, [d length] - _parseOffset)];
|
||||||
}
|
}
|
||||||
_parseOffset = bodyLength;
|
_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 read failed ... dropped, but parsing is not complete.
|
||||||
* The request was sent, so we can't know whether it was
|
* 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);
|
NSLog(@"HTTP response not received - %@", _parser);
|
||||||
}
|
}
|
||||||
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self didFailWithError:
|
[this->client URLProtocol: self didFailWithError:
|
||||||
[NSError errorWithDomain: @"receive incomplete"
|
[NSError errorWithDomain: @"receive incomplete"
|
||||||
code: 0
|
code: 0
|
||||||
|
@ -986,6 +997,7 @@ static NSURLProtocol *placeholder = nil;
|
||||||
NSLog(@"error reading from HTTPBody stream %@",
|
NSLog(@"error reading from HTTPBody stream %@",
|
||||||
[NSError _last]);
|
[NSError _last]);
|
||||||
}
|
}
|
||||||
|
[self stopLoading];
|
||||||
[this->client URLProtocol: self didFailWithError:
|
[this->client URLProtocol: self didFailWithError:
|
||||||
[NSError errorWithDomain: @"can't read body"
|
[NSError errorWithDomain: @"can't read body"
|
||||||
code: 0
|
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);
|
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]];
|
[this->client URLProtocol: self didFailWithError: [stream streamError]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue