(file) Return to HTTPMessage.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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 marek  1.36     bool binaryResponse;
 78 kumpf  1.26 
 79 marek  1.37     Boolean parse(
 80 kumpf  1.26         String& startLine,
 81                     Array<HTTPHeader>& headers,
 82                     Uint32& contentLength) const;
 83             
 84 lawrence.luo 1.39 
 85 kumpf        1.26     void printAll(PEGASUS_STD(ostream)& os) const;
 86 lawrence.luo 1.39 
 87 kumpf        1.26 
 88                       static void lookupHeaderPrefix(
 89                           Array<HTTPHeader>& headers,
 90 kumpf        1.35         const char* fieldName,
 91 kumpf        1.26         String& prefix);
 92                   
 93                       static Boolean lookupHeader(
 94                           Array<HTTPHeader>& headers,
 95 kumpf        1.35         const char* fieldName,
 96 kumpf        1.26         String& fieldValue,
 97                           Boolean allowNamespacePrefix = false);
 98                   
 99 kumpf        1.35     static Boolean lookupHeader(
100                           Array<HTTPHeader>& headers,
101                           const char* fieldName,
102                           const char*& fieldValue,
103                           Boolean allowNamespacePrefix = false);
104                   
105 kumpf        1.26     static Boolean parseRequestLine(
106                           const String& startLine,
107                           String& methodName,
108                           String& requestUri,
109                           String& httpVersion);
110                   
111                       static Boolean parseStatusLine(
112                           const String& statusLine,
113                           String& httpVersion,
114                           Uint32& statusCode,
115                           String& reasonPhrase);
116 venkat.puvvada 1.28 
117 kumpf          1.31     static Boolean parseContentTypeHeader(
118 kumpf          1.35         const char* contentTypeHeader,
119 kumpf          1.31         String& type,
120                             String& charset);
121                     
122 thilo.boehm    1.30     static Boolean parseLocalAuthHeader(
123                             const String& authHeader,
124                             String& authType,
125                             String& userName,
126                             String& cookie);
127                     
128                         static Boolean parseHttpAuthHeader(
129                             const String& authHeader,
130                             String& authType,
131                             String& cookie);
132                     
133 jsafrane       1.40     static Boolean parseCookieHeader(
134                             const String& cookieHeader,
135                             const String& name,
136                             String &value);
137                     
138 sushma.fernandes 1.29     /**
139                               Advances a given pointer to the first character that is not
140                               HTTP header whitespace (space or tabs).
141                       
142                               @param  str    Input string.
143                           */
144                           static void skipHeaderWhitespace(const char*& str);
145                       
146                           /**
147                               Looks for a token in the beginning of a given string.
148                       
149                               @param  str    input string to be searched
150                               @param  token  token to look for
151 kumpf            1.34 
152                               @return true   if the token is found in the string after skipping
153 sushma.fernandes 1.29                         the leading whitespaces if any.
154                               @return false  if the token is not found.
155                           */
156                           static Boolean expectHeaderToken(const char*& str, const char *token);
157                       
158                           /**
159                               Returns a pointer to the first CRLF or a LF separator.
160                       
161 kumpf            1.34         @param  data   input string.
162 marek            1.38         
163 kumpf            1.34         @return pointer to the first CRLF or LF separator if any, else
164 sushma.fernandes 1.29                 returns NULL.
165                           */
166 marek            1.38     static char* findSeparator(const char* data);
167 kumpf            1.35 
168 jsafrane         1.40     /**
169                               Add a header just after the status line. This method can be used
170                               to modify a message just before it is sent.
171                       
172                               @param header   Complete header, in format "\r\nName: value". Especially
173                               note the starting whitespace characters!
174                            */
175                           void injectHeader(const String &header);
176                       
177 kumpf            1.35 private:
178                       
179                           static Boolean _lookupHeaderIndex(
180                               Array<HTTPHeader>& headers,
181                               const char* fieldName,
182                               Uint32& headerIndex,
183                               Boolean allowNamespacePrefix);
184 kumpf            1.4  };
185 kumpf            1.5  
186                       PEGASUS_NAMESPACE_END
187 mike             1.2  
188                       #endif /* Pegasus_HTTPMessage_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2