Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: WebObjects/WOMessage.h
WOMessage is the parent class for both WORequest and WOResponse,and implements much of the behavior that is generic to both. WOMessage represents a message with an HTTP header and either HTML or XML content. HTML content is typically used when interacting with a Web browser, while XML content can be used in messages that originate from or are destined for another application (either an application that "speaks" XML or another WebObjects application).
The methods of the WOMessage class can be divided primarily into two groups, those that deal with a message's content and those that read and set header information. Most of the remaining WOMessage methods control how the content is encoded and allow you to attach arbitrary "user info" to your WOMessage objects in order to pass information about a given message to other objects within your application.
Headers are case-insensitive. WebObjects enforces the HTTP specification, but avoid mixing the case of header keys. See the HTTP specification or HTTP documentation for more information on the HTTP headers and version. |
int Value | WebObjects Name | Notes |
1 | NSASCIIStringEncoding | 0 through 127 |
2 | NSNEXTSTEPStringEncoding | |
3 | NSJapaneseEUCStringEncoding | |
4 | NSUTF8StringEncoding | |
5 | NSISOLatin1StringEncoding | default |
6 | NSSymbolStringEncoding | |
7 | NSNonLossyASCIIStringEncoding | 7-bit verbose ASCII to represent all unichars |
8 | NSShiftJISStringEncoding | |
9 | NSISOLatin2StringEncoding | |
10 | NSUnicodeStringEncoding | |
11 | NSWindowsCP1251StringEncoding | Cyrillic; same as AdobeStandardCyrillic |
12 | NSWindowsCP1252StringEncoding | Windows Latin1 |
13 | NSWindowsCP1253StringEncoding | Windows Greek |
14 | NSWindowsCP1254StringEncoding | Windows Turkish |
15 | NSWindowsCP1250StringEncoding | Windows Latin2 |
21 | NSISO2022JPStringEncoding | ISO 2022 Japanese encoding for electronic mail |
.
NSCopying- copy - copyWithZone:
- Creation
- - init
- Working with message headers
- - appendHeader:forKey:
- - appendHeaders:forKey:
- - headerForKey:
- - headerKeys
- - headers
- - headersForKey:
- - httpVersion
- - removeHeadersForKey:
- - setHeader:forKey:
- - setHeaders:
- - setHeaders:forKey:
- - setHTTPVersion:
- Working with message content
- - addCookie:
- - appendContentBytes:length:
- - appendContentCharacter:
- - appendContentData:
- - appendContentString:
- - content
- - cookies
- - removeCookie:
- - setContent:
- Controlling content encoding
- + defaultEncoding
- + setDefaultEncoding:
- - contentEncoding
- - setContentEncoding:
- Working with user info
- - setUserInfo:
- - userInfo
+ (NSStringEncoding)defaultEncoding
+ (void)setDefaultEncoding:(NSStringEncoding)aStringEncoding
- (void)addCookie:(WOCookie
*)aCookie
See Also: - cookies, - removeCookie:, WOCookie class specification
- (void)appendContentBytes:(const
void *)someBytes
length:(unsigned)length
- (void)appendContentCharacter:(char)aChar
Example:
// ... if (aFlag) [aResponse appendContentCharacter:'Y']; else [aResponse appendContentCharacter:'N'];
- (void)appendContentData:(NSData
*)dataObject
- (void)appendContentString:(NSString
*)aString
- (void)appendHeader:(NSString
*)aHeader
forKey:(NSString *)aKey
[aResponse appendHeader:@"text/html" forKey:@"content-type"];
See Also: - headerForKey:, - setHeader:forKey:
- (void)appendHeaders:(NSArray
*)headerList
forKey:(NSString *)aKey
See Also: - headerKeys, - headersForKey:, - setHeaders:forKey:
- (NSData *)content
An exception is raised if you attempt to get the content when all elements of the page have not had their chance to append HTML to the response. Thus, you should invoke this method in the application object's handleRequest: method, after super's handleRequest: has been invoked. (For scripted applications, handleRequest: is implemented in Application.wos). Note that at this point in the request-handling process, the components, pages, and session have already been put to sleep, so you won't have access to any context, session, or page information. If you need such information for your response, store it somewhere--such as in WOMessage's "user info" dictionary-at a point when you do have access to it. You may want to do this in your application's appendToResponse:inContext: method, for example.
See Also: - setContent:, - setContentEncoding:
- (NSStringEncoding)contentEncoding
NSStringEncoding theEncoding = [[aContext request] formValueEncoding];
The default string encoding is ISO Latin1.
See Also: - setContent:, - setContentEncoding:
- (NSArray *)cookies
See Also: - addCookie:, - removeCookie:, WOCookie class specification
- (NSString *)headerForKey:(NSString
*)aKey
See Also: - setHeader:forKey:
- (NSArray *)headerKeys
NSArray *hKeys = [aMessage headerKeys]; if ([hKeys containsObject:@"expires"]) { // do something }
See Also: - setHeaders:forKey:
- (NSDictionary *)headers
- (NSArray *)headersForKey:(NSString
*)aKey
See Also: - setHeaders:forKey:
- (NSString *)httpVersion
See Also: - setHTTPVersion:
- (id)init
- (void)removeCookie:(WOCookie
*)aCookie
See Also: - cookies, - removeCookie:, WOCookie class specification
- (void)removeHeadersForKey:(NSString
*)aKey
See Also: - headerKeys, - headersForKey:, - setHeaders:forKey:
- (void)setContent:(NSData
*)someData
See Also: - content
- (void)setContentEncoding:(NSStringEncoding)anEncoding
See Also: - contentEncoding
- (void)setHTTPVersion:(NSString
*)aVersion
See Also: - httpVersion
- (void)setHeader:(NSString
*)aHeader
forKey:(NSString *)aKey
[aResponse setHeader:@"text/html" forKey:@"content-type"];
See Also: - appendHeader:forKey:, - headerForKey:
- (void)setHeaders:(NSDictionary
*)headerDictionary
For each key in headerDictionary, appends the corresponding value to the list of HTTP headers in the receiver and associates, for retrieval, the dictionary key with the header value. If a header doesn't already exist for the receiver, one is created before the list of headers is appended.
See Also: - headers, - removeHeadersForKey:
- (void)setHeaders:(NSArray *)headerList
forKey:(NSString *)aKey
See Also: - appendHeaders:forKey:, - headerKeys, - headersForKey:
- (void)setUserInfo:(NSDictionary
*)aDictionary
- (NSDictionary *)userInfo
See Also: - setUserInfo: