2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef __NGObjWeb_WOMessage_H__
23 #define __NGObjWeb_WOMessage_H__
25 #import <Foundation/NSObject.h>
26 #import <Foundation/NSString.h>
27 #include <NGStreams/NGStreamProtocols.h>
32 Abstract superclass of both, WORequest and WOResponse.
35 @class NSDictionary, NSArray, NSData, NSMutableData, NSMutableArray;
36 @class NGMutableHashMap;
39 @interface WOMessage : NSObject
43 NSMutableData *content;
44 NGMutableHashMap *header;
45 NSDictionary *userInfo;
46 NSMutableArray *cookies;
47 NSStringEncoding contentEncoding;
48 id<NGStream> contentStream;
52 BOOL didStartWriting:1; // afterwards no headers may be changed
56 @public // cached selectors
57 void (*addChar)(id, SEL, char);
58 void (*addStr)(id, SEL, NSString *);
59 void (*addHStr)(id, SEL, NSString *);
60 void (*addCStr)(id, SEL, const unsigned char *);
61 void (*addBytes)(id, SEL, const void *, unsigned);
66 - (void)setUserInfo:(NSDictionary *)_userInfo;
67 - (NSDictionary *)userInfo;
71 - (void)setHTTPVersion:(NSString *)_httpVersion;
72 - (NSString *)httpVersion;
74 /* cookies (new in WO4) */
76 - (void)addCookie:(WOCookie *)_cookie;
77 - (void)removeCookie:(WOCookie *)_cookie;
82 - (void)setHeader:(NSString *)_header forKey:(NSString *)_key;
83 - (NSString *)headerForKey:(NSString *)_key;
84 - (void)setHeaders:(NSArray *)_headers forKey:(NSString *)_key;
85 - (NSArray *)headersForKey:(NSString *)_key;
86 - (NSArray *)headerKeys;
88 - (void)appendHeader:(NSString *)_header forKey:(NSString *)_key;
89 - (void)appendHeaders:(NSArray *)_headers forKey:(NSString *)_key;
91 - (void)setHeaders:(NSDictionary *)_headers;
92 - (NSDictionary *)headers;
93 - (NSString *)headersAsString;
97 - (void)setContent:(NSData *)_data;
99 - (void)setContentEncoding:(NSStringEncoding)_encoding;
100 - (NSStringEncoding)contentEncoding;
101 + (void)setDefaultEncoding:(NSStringEncoding)_encoding;
102 + (NSStringEncoding)defaultEncoding;
104 /* structured content */
106 - (void)appendContentBytes:(const void *)_bytes length:(unsigned)_length;
107 - (void)appendContentCharacter:(unichar)_c;
108 - (void)appendContentData:(NSData *)_data;
110 - (void)appendContentString:(NSString *)_value;
111 - (void)appendContentCString:(const unsigned char *)_value;
113 - (void)appendContentHTMLAttributeValue:(NSString *)_value;
114 - (void)appendContentHTMLString:(NSString *)_value;
115 - (void)appendContentXMLAttributeValue:(NSString *)_value;
116 - (void)appendContentXMLString:(NSString *)_value;
120 @interface WOMessage(Escaping)
122 /* this escapes '&', '"', '<' and '>' */
123 + (NSString *)stringByEscapingHTMLString:(NSString *)_string;
125 /* this escapes '&', '"', '<', '>', '\t', '\r' and '\n' */
126 + (NSString *)stringByEscapingHTMLAttributeValue:(NSString *)_string;
130 @interface WOMessage(NGObjWebExtensions)
131 - (NSString *)contentAsString;
132 - (BOOL)doesStreamContent;
133 - (NSArray *)validateContent;
136 @interface WOMessage(DOMXML)
137 - (void)setContentDOMDocument:(id)_dom;
138 - (void)appendContentDOMDocumentFragment:(id)_domfrag;
139 - (id)contentAsDOMDocument;
142 #endif /* __NGObjWeb_WOMessage_H__ */