tweak header parsing

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28687 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-09-15 15:28:35 +00:00
parent 75638580ff
commit 6455c3e533
2 changed files with 21 additions and 2 deletions

View file

@ -203,6 +203,7 @@ extern "C" {
unsigned int buggyQuotes:1;
unsigned int wantEndOfLine:1;
unsigned int excessData:1;
unsigned int headersOnly:1;
} flags;
NSData *boundary; // Also overloaded to hold excess
GSMimeDocument *document;
@ -237,6 +238,7 @@ extern "C" {
- (NSString*) scanToken: (NSScanner*)scanner;
- (void) setBuggyQuotes: (BOOL)flag;
- (void) setDefaultCharset: (NSString*)aName;
- (void) setHeadersOnly;
- (void) setIsHttp;
@end

View file

@ -1416,12 +1416,21 @@ wordData(NSString *word)
* If there is a zero content length, all parsing is complete,
* not just header parsing.
*/
hdr = [document headerNamed: @"content-length"];
if (hdr != nil && [[hdr value] intValue] == 0)
if (flags.headersOnly == 1
|| ((hdr = [document headerNamed: @"content-length"]) != nil
&& [[hdr value] intValue] == 0))
{
[document setContent: @""];
flags.inBody = 0;
flags.complete = 1;
/* If we have more data after the headers ... it's excess and
* should become available as excess data.
*/
if ([d length] > 0)
{
ASSIGNCOPY(boundary, d);
flags.excessData = 1;
}
}
return NO; // No more data needed
@ -2093,6 +2102,14 @@ NSDebugMLLog(@"GSMime", @"Header parsed - %@", info);
}
}
/**
* Method to inform the parser that only the headers should be parsed
* and any remaining data be treated as excess
*/
- (void) setHeadersOnly
{
flags.headersOnly = 1;
}
/**
* Method to inform the parser that the data it is parsing is an HTTP