WOResponse
Inherits from: WOMessage NSObject
Conforms to: WOActionResults NSObject
(NSObject)
Declared in: WebObjects/WOResponse.h
Class Description
A WOResponse object represents an HTTP response that an application returns to a Web server to complete a cycle of the request-response loop. The composition of a response occurs during the third and final phase of this loop, a phase marked by the propagation of the appendToResponse:inContext: message through the objects of the application. The WOApplication object first sends this message, passing in a newly-created WOResponse object as an argument. WOElement objects, which represent the dynamic and static HTML elements on a page, respond to the message by appending their HTML representation to the content of the WOResponse object. WOApplication, WOSession, and WOComponent objects can also respond to the message by adding information to the WOResponse object.
A WOResponse has two major parts: HTML content and HTTP information. The content is what is displayed in a Web browser; it can include escaped HTML, which is HTML code shown "as is," uninterpreted. The other information encapsulated by a WOResponse object is used when handling the response. This HTTP data includes headers, status codes, and version string. See the HTTP specification or HTTP documentation for descriptions of these items.
The WOMessage class-from which WOResponse inherits-declares most of the methods you use when constructing a response. These methods can be divided into two groups, those that add to a response's HTML content and those that read and set HTTP information. To the methods provided by WOMessage, the WOResponse class adds two methods that escape HTML ( appendContentHTMLAttributeValue: and appendContentHTMLString:). For images and other binary data, use appendContentData: (declared in the WOMessage class). You can obtain and set the entire content of the response with WOMessage's content and setContent: methods. The following example shows a sequence of appendContent... messages that compose an HTTP "POST" message:
[aResponse appendContentString:@"<form method=\"POST\" action=\""]; [aResponse appendContentHTMLAttributeValue:[aContext url]]; [aResponse appendContentCharacter:'"']; [aResponse.appendContentString:@">"];
The remaining WOResponse instance methods set and read the the HTTP status code. WOResponse also provides two class methods that allow you to escape NSString objects.
Adopted Protocols
NSCopying- copy - copyWithZone: WOActionResults- generateResponse
Method Types
- Creation
- - init
- Working with HTTP status
- - setStatus:
- - status
- Working with HTML content
- - appendContentHTMLAttributeValue:
- - appendContentHTMLString:
- - generateResponse
- + stringByEscapingHTMLString:
- + stringByEscapingHTMLAttributeValue:
- Controlling Client Caching
- - disableClientCaching
Class Methods
stringByEscapingHTMLAttributeValue:
+ (NSString *)stringByEscapingHTMLAttributeValue:(NSString
*)aString
Character | Escaped character |
& | & |
" | " |
\t | |
\n | |
\r | |
< | < |
> | > |
stringByEscapingHTMLString:
+ (NSString *)stringByEscapingHTMLString:(NSString
*)aString
Character | Escaped character |
& | & |
" | " |
< | < |
> | > |
Instance Methods
appendContentHTMLAttributeValue:
- (void)appendContentHTMLAttributeValue:(NSString
*)aValue
[aResponse appendContentHTMLAttributeValue:@"<B>"];
would transform the argument to "<B>".
See Also: - setContentEncoding: ( WOMessage class)
appendContentHTMLString:
- (void)appendContentHTMLString:(NSString
*)aString
See Also: - setContentEncoding: ( WOMessage class)
disableClientCaching
- (void)disableClientCaching
Attempts to disable caching in the client browser by appending a "no-cache" Cache-Control response directive to the HTTP response and by appending Expires and Date values that equal (they are both set to the current date and time).
This method shouldn't be invoked more than once for a given response.
generateResponse
- (WOResponse *)generateResponse
See Also: - generateResponse (WOComponent)
init
- (id)init
setStatus:
- (void)setStatus:(unsigned
int)anInt
See Also: - status
status
- (unsigned int)status
By default, the status is 200 ("OK" status).
See Also: - setStatus: