mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
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:
parent
a74def5b73
commit
5a8fbf7417
2 changed files with 21 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue