1 //%/////////////////////////////////////////////////////////////////////////////
\r
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
\r
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 // of this software and associated documentation files (the "Software"), to
\r
7 // deal in the Software without restriction, including without limitation the
\r
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
\r
9 // sell copies of the Software, and to permit persons to whom the Software is
\r
10 // furnished to do so, subject to the following conditions:
\r
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
\r
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
\r
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
\r
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
\r
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
\r
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
21 //==============================================================================
\r
23 // Author: Mike Brasher (mbrasher@bmc.com)
\r
27 //%/////////////////////////////////////////////////////////////////////////////
\r
29 ////////////////////////////////////////////////////////////////////////////////
\r
33 // This handler processes HTTP messages which have the following format:
\r
35 // lines (one or more CRLF-terminated lines)
\r
36 // terminator (CRLF on line by itself)
\r
37 // message-body (optional depending on message type)
\r
39 ////////////////////////////////////////////////////////////////////////////////
\r
41 #ifndef Pegasus_Handler_h
\r
42 #define Pegasus_Handler_h
\r
45 #include <strstream>
\r
46 #include <Pegasus/Common/Config.h>
\r
47 #include <Pegasus/Common/Array.h>
\r
48 #include <Pegasus/Common/String.h>
\r
49 #include <Pegasus/Common/Channel.h>
\r
50 #include <Pegasus/Common/Logger.h>
\r
52 PEGASUS_NAMESPACE_BEGIN
\r
54 class PEGASUS_PROTOCOL_LINKAGE Handler : public ChannelHandler
\r
62 virtual Boolean handleOpen(Channel* channel);
\r
64 virtual Boolean handleInput(Channel* channel);
\r
66 virtual Boolean handleOutput(Channel* channel);
\r
68 virtual void handleClose(Channel* channel);
\r
72 void skipWhitespace(const char*& p);
\r
74 const char* getFieldValue(const char* fieldName) const;
\r
76 const char* getFieldValueSubString(const char* str) const;
\r
78 const char* getContent() const;
\r
80 Uint32 getContentLength() const;
\r
86 //void logMessage(LogFileType logFileType, String& subsystem,
\r
87 // Uint32 severity, String& formatMsg) const;
\r
89 virtual int handleMessage();
\r
91 static void printMessage(PEGASUS_STD(ostream)& os, const Array<Sint8>& message);
\r
93 static void setMessageTrace(const Boolean flag)
\r
95 _messageTrace = flag;
\r
97 static void setMessageLogTrace(const Boolean flag)
\r
99 _messageLogTrace = flag;
\r
106 enum State { WAITING, LINES, CONTENT, DONE };
\r
112 Array<char> _message;
\r
113 Array<Uint32> _lines;
\r
114 Uint32 _contentOffset;
\r
115 Uint32 _contentLength;
\r
116 static Boolean _messageTrace;
\r
117 static Boolean _messageLogTrace;
\r
120 PEGASUS_NAMESPACE_END
\r
122 #endif /* Pegasus_Handler_h */
\r