]> err.no Git - sope/blob - sope-appserver/NGObjWeb/NGObjWeb/WOMessage.h
improved SOPE security exceptions
[sope] / sope-appserver / NGObjWeb / NGObjWeb / WOMessage.h
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #ifndef __NGObjWeb_WOMessage_H__
23 #define __NGObjWeb_WOMessage_H__
24
25 #import <Foundation/NSObject.h>
26 #import <Foundation/NSString.h>
27 #include <NGStreams/NGStreamProtocols.h>
28
29 /*
30   WOMessage
31   
32   Abstract superclass of both, WORequest and WOResponse.
33 */
34
35 @class NSDictionary, NSArray, NSData, NSMutableData, NSMutableArray;
36 @class NGMutableHashMap;
37 @class WOCookie;
38
39 @interface WOMessage : NSObject
40 {
41 @private
42   NSString         *version;
43   NSMutableData    *content;
44   NGMutableHashMap *header;
45   NSDictionary     *userInfo;
46   NSMutableArray   *cookies;
47   NSStringEncoding contentEncoding;
48   id<NGStream>     contentStream;
49   id               domCache;
50   
51   struct {
52     BOOL didStartWriting:1; // afterwards no headers may be changed
53     int  reserved:31;
54   } womFlags;
55   
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);
62 }
63
64 /* accessors */
65
66 - (void)setUserInfo:(NSDictionary *)_userInfo;
67 - (NSDictionary *)userInfo;
68
69 /* HTTP */
70
71 - (void)setHTTPVersion:(NSString *)_httpVersion;
72 - (NSString *)httpVersion;
73
74 /* cookies (new in WO4) */
75
76 - (void)addCookie:(WOCookie *)_cookie;
77 - (void)removeCookie:(WOCookie *)_cookie;
78 - (NSArray *)cookies;
79
80 /* header */
81
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;
87
88 - (void)appendHeader:(NSString *)_header forKey:(NSString *)_key;
89 - (void)appendHeaders:(NSArray *)_headers forKey:(NSString *)_key;
90
91 - (void)setHeaders:(NSDictionary *)_headers;
92 - (NSDictionary *)headers;
93 - (NSString *)headersAsString;
94
95 /* generic content */
96
97 - (void)setContent:(NSData *)_data;
98 - (NSData *)content;
99 - (void)setContentEncoding:(NSStringEncoding)_encoding;
100 - (NSStringEncoding)contentEncoding;
101 + (void)setDefaultEncoding:(NSStringEncoding)_encoding;
102 + (NSStringEncoding)defaultEncoding;
103
104 /* structured content */
105
106 - (void)appendContentBytes:(const void *)_bytes length:(unsigned)_length;
107 - (void)appendContentCharacter:(unichar)_c;
108 - (void)appendContentData:(NSData *)_data;
109
110 - (void)appendContentString:(NSString *)_value;
111 - (void)appendContentCString:(const unsigned char *)_value;
112
113 - (void)appendContentHTMLAttributeValue:(NSString *)_value;
114 - (void)appendContentHTMLString:(NSString *)_value;
115 - (void)appendContentXMLAttributeValue:(NSString *)_value;
116 - (void)appendContentXMLString:(NSString *)_value;
117
118 @end
119
120 @interface WOMessage(Escaping)
121
122 /* this escapes '&', '"', '<' and '>' */
123 + (NSString *)stringByEscapingHTMLString:(NSString *)_string;
124
125 /* this escapes '&', '"', '<', '>', '\t', '\r' and '\n' */
126 + (NSString *)stringByEscapingHTMLAttributeValue:(NSString *)_string;
127
128 @end
129
130 @interface WOMessage(NGObjWebExtensions)
131 - (NSString *)contentAsString;
132 - (BOOL)doesStreamContent;
133 - (NSArray *)validateContent;
134 @end
135
136 @interface WOMessage(DOMXML)
137 - (void)setContentDOMDocument:(id)_dom;
138 - (void)appendContentDOMDocumentFragment:(id)_domfrag;
139 - (id)contentAsDOMDocument;
140 @end
141
142 #endif /* __NGObjWeb_WOMessage_H__ */