mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 02:01:03 +00:00
Make handling of incoming http response more robust.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14472 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4e46a9170d
commit
f72d14030c
2 changed files with 52 additions and 31 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
* Tools/AGSParser.m: Bugfix ... look for source files more
|
* Tools/AGSParser.m: Bugfix ... look for source files more
|
||||||
intelligently. Try both current directory and relative to header.
|
intelligently. Try both current directory and relative to header.
|
||||||
|
* Source/GSHTTPURLHandle.m: If response parsing fails, fail the
|
||||||
|
load operation and (conditionally when debug enabled) log an error.
|
||||||
|
|
||||||
2002-09-16 Richard Frith-Macdonald <rfm@gnu.org>
|
2002-09-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,8 @@ static void debugWrite(NSData *data)
|
||||||
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
d = [dict objectForKey: NSFileHandleNotificationDataItem];
|
||||||
if (debug == YES) debugRead(d);
|
if (debug == YES) debugRead(d);
|
||||||
|
|
||||||
[parser parse: d];
|
if ([parser parse: d] == NO)
|
||||||
|
{
|
||||||
if ([parser isComplete] == YES)
|
if ([parser isComplete] == YES)
|
||||||
{
|
{
|
||||||
GSMimeHeader *info;
|
GSMimeHeader *info;
|
||||||
|
@ -313,19 +314,27 @@ static void debugWrite(NSData *data)
|
||||||
object: sock];
|
object: sock];
|
||||||
[sock closeFile];
|
[sock closeFile];
|
||||||
DESTROY(sock);
|
DESTROY(sock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Retrieve essential keys from document
|
* Retrieve essential keys from document
|
||||||
*/
|
*/
|
||||||
info = [document headerNamed: @"http"];
|
info = [document headerNamed: @"http"];
|
||||||
val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey];
|
val = [info objectForKey: NSHTTPPropertyServerHTTPVersionKey];
|
||||||
if (val != nil)
|
if (val != nil)
|
||||||
[pageInfo setObject: val forKey: NSHTTPPropertyServerHTTPVersionKey];
|
{
|
||||||
|
[pageInfo setObject: val
|
||||||
|
forKey: NSHTTPPropertyServerHTTPVersionKey];
|
||||||
|
}
|
||||||
val = [info objectForKey: NSHTTPPropertyStatusCodeKey];
|
val = [info objectForKey: NSHTTPPropertyStatusCodeKey];
|
||||||
if (val != nil)
|
if (val != nil)
|
||||||
|
{
|
||||||
[pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey];
|
[pageInfo setObject: val forKey: NSHTTPPropertyStatusCodeKey];
|
||||||
|
}
|
||||||
val = [info objectForKey: NSHTTPPropertyStatusReasonKey];
|
val = [info objectForKey: NSHTTPPropertyStatusReasonKey];
|
||||||
if (val != nil)
|
if (val != nil)
|
||||||
|
{
|
||||||
[pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey];
|
[pageInfo setObject: val forKey: NSHTTPPropertyStatusReasonKey];
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Tell superclass that we have successfully loaded the data.
|
* Tell superclass that we have successfully loaded the data.
|
||||||
*/
|
*/
|
||||||
|
@ -335,6 +344,16 @@ static void debugWrite(NSData *data)
|
||||||
[self didLoadBytes: [d subdataWithRange: r]
|
[self didLoadBytes: [d subdataWithRange: r]
|
||||||
loadComplete: YES];
|
loadComplete: YES];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (debug == YES)
|
||||||
|
{
|
||||||
|
NSLog(@"HTTP parse failure - %@", parser);
|
||||||
|
}
|
||||||
|
[self endLoadInBackground];
|
||||||
|
[self backgroundLoadDidFailWithReason: @"Response parse failed"];
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue