1 martin 1.32 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.33 //
|
3 martin 1.32 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.33 //
|
10 martin 1.32 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.33 //
|
17 martin 1.32 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.33 //
|
20 martin 1.32 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.33 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.32 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.33 //
|
28 martin 1.32 //////////////////////////////////////////////////////////////////////////
|
29 mike 1.2 //
30 //%/////////////////////////////////////////////////////////////////////////////
31
32 #ifndef Pegasus_HTTPMessage_h
33 #define Pegasus_HTTPMessage_h
34
35 #include <iostream>
36 #include <Pegasus/Common/Config.h>
37 #include <Pegasus/Common/MessageQueue.h>
38 #include <Pegasus/Common/Pair.h>
39 #include <Pegasus/Common/String.h>
40 #include <Pegasus/Common/Message.h>
|
41 kumpf 1.13 #include <Pegasus/Common/ArrayInternal.h>
|
42 mike 1.2 #include <Pegasus/Common/AuthenticationInfo.h>
|
43 kumpf 1.12 #include <Pegasus/Common/Linkage.h>
|
44 kumpf 1.23 #include <Pegasus/Common/AcceptLanguageList.h>
45 #include <Pegasus/Common/ContentLanguageList.h>
|
46 mike 1.22 #include <Pegasus/Common/Buffer.h>
|
47 mike 1.2
48 PEGASUS_NAMESPACE_BEGIN
49
|
50 kumpf 1.35 typedef Pair<Buffer, Buffer> HTTPHeader;
|
51 mike 1.2
52 /** This message is sent from a connection to its output queue when
53 a complete HTTP message is received.
54 */
55 class PEGASUS_COMMON_LINKAGE HTTPMessage : public Message
56 {
|
57 kumpf 1.26 public:
|
58 kumpf 1.27
|
59 kumpf 1.26 typedef Message Base;
|
60 kumpf 1.27
|
61 kumpf 1.26 HTTPMessage(
62 const Buffer& message_,
63 Uint32 queueId_ = 0,
64 const CIMException* cimException_ = 0);
65
66 HTTPMessage(const HTTPMessage & msg);
67
68 Buffer message;
69 Uint32 queueId;
70 String ipAddress;
71 AuthenticationInfo* authInfo;
72 AcceptLanguageList acceptLanguages;
73 ContentLanguageList contentLanguages;
74 Boolean acceptLanguagesDecoded;
75 Boolean contentLanguagesDecoded;
76 CIMException cimException;
77
|
78 marek 1.35.6.1 Boolean parse(
|
79 kumpf 1.26 String& startLine,
80 Array<HTTPHeader>& headers,
81 Uint32& contentLength) const;
82
83 #ifdef PEGASUS_DEBUG
84 void printAll(PEGASUS_STD(ostream)& os) const;
85 #endif
86
87 static void lookupHeaderPrefix(
88 Array<HTTPHeader>& headers,
|
89 kumpf 1.35 const char* fieldName,
|
90 kumpf 1.26 String& prefix);
91
92 static Boolean lookupHeader(
93 Array<HTTPHeader>& headers,
|
94 kumpf 1.35 const char* fieldName,
|
95 kumpf 1.26 String& fieldValue,
96 Boolean allowNamespacePrefix = false);
97
|
98 kumpf 1.35 static Boolean lookupHeader(
99 Array<HTTPHeader>& headers,
100 const char* fieldName,
101 const char*& fieldValue,
102 Boolean allowNamespacePrefix = false);
103
|
104 kumpf 1.26 static Boolean parseRequestLine(
105 const String& startLine,
106 String& methodName,
107 String& requestUri,
108 String& httpVersion);
109
110 static Boolean parseStatusLine(
111 const String& statusLine,
112 String& httpVersion,
113 Uint32& statusCode,
114 String& reasonPhrase);
|
115 venkat.puvvada 1.28
|
116 kumpf 1.31 static Boolean parseContentTypeHeader(
|
117 kumpf 1.35 const char* contentTypeHeader,
|
118 kumpf 1.31 String& type,
119 String& charset);
120
|
121 thilo.boehm 1.30 static Boolean parseLocalAuthHeader(
122 const String& authHeader,
123 String& authType,
124 String& userName,
125 String& cookie);
126
127 static Boolean parseHttpAuthHeader(
128 const String& authHeader,
129 String& authType,
130 String& cookie);
131
|
132 sushma.fernandes 1.29 /**
133 Advances a given pointer to the first character that is not
134 HTTP header whitespace (space or tabs).
135
136 @param str Input string.
137 */
138 static void skipHeaderWhitespace(const char*& str);
139
140 /**
141 Looks for a token in the beginning of a given string.
142
143 @param str input string to be searched
144 @param token token to look for
|
145 kumpf 1.34
146 @return true if the token is found in the string after skipping
|
147 sushma.fernandes 1.29 the leading whitespaces if any.
148 @return false if the token is not found.
149 */
150 static Boolean expectHeaderToken(const char*& str, const char *token);
151
152 /**
153 Returns a pointer to the first CRLF or a LF separator.
154
|
155 kumpf 1.34 @param data input string.
|
156 sushma.fernandes 1.29 @param size size of the input string.
|
157 kumpf 1.34
158 @return pointer to the first CRLF or LF separator if any, else
|
159 sushma.fernandes 1.29 returns NULL.
160 */
161 static char* findSeparator(
162 const char* data,
163 Uint32 size);
|
164 kumpf 1.35
165 private:
166
167 static Boolean _lookupHeaderIndex(
168 Array<HTTPHeader>& headers,
169 const char* fieldName,
170 Uint32& headerIndex,
171 Boolean allowNamespacePrefix);
|
172 kumpf 1.4 };
|
173 kumpf 1.5
174 PEGASUS_NAMESPACE_END
|
175 mike 1.2
176 #endif /* Pegasus_HTTPMessage_h */
|