mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Added setContentType:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17790 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
caf2c322de
commit
089a040482
2 changed files with 30 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-10-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSMime.m: ([GSMimeDocument-setContentType:])
|
||||
New convenience method.
|
||||
|
||||
2003-10-05 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Documentation/GNUmakefile: Make manual
|
||||
|
|
|
@ -4412,6 +4412,31 @@ static NSCharacterSet *tokenSet = nil;
|
|||
RELEASE(arp);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Convenience method to set the content type of the document without
|
||||
* altering any content.
|
||||
* The supplied newType may be full type information including subtype
|
||||
* and parameters as found after the colon in a mime Content-Type header.
|
||||
* </p>
|
||||
*/
|
||||
- (void) setContentType: (id)newType
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
GSMimeHeader *hdr = nil;
|
||||
GSMimeParser *p = AUTORELEASE([GSMimeParser new]);
|
||||
NSScanner *scanner = [NSScanner scannerWithString: newType];
|
||||
|
||||
hdr = AUTORELEASE([GSMimeHeader new]);
|
||||
[hdr setName: @"content-type"];
|
||||
if ([p scanHeaderBody: scanner into: hdr] == NO)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"Unable to parse type information"];
|
||||
}
|
||||
[self setHeader: hdr];
|
||||
RELEASE(arp);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method may be called to set a header in the document.
|
||||
* Any other headers with the same name will be removed from
|
||||
|
|
Loading…
Reference in a new issue