1 karl 1.45 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.29 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.22 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.29 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.36 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.45 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.2 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.11 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.45 //
|
21 kumpf 1.11 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.11 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Mike Brasher (mbrasher@bmc.com)
33 //
34 // Modified By:
35 // Nag Boranna, Hewlett-Packard Company(nagaraja_boranna@hp.com)
36 // Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
|
37 brian.campbell 1.27 // Brian G. Campbell, EMC (campbell_brian@emc.com) - PEP140/phase1
|
38 a.arora 1.32 // Amit K Arora, IBM (amita@in.ibm.com) for Bug#1097, #2541
|
39 david.dillard 1.33 // David Dillard, VERITAS Software Corp. (david.dillard@veritas.com)
|
40 kumpf 1.34 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
41 mike 1.2 //
42 //%/////////////////////////////////////////////////////////////////////////////
43
44 #ifndef Pegasus_HTTPConnection_h
45 #define Pegasus_HTTPConnection_h
46
47 #include <iostream>
|
48 brian.campbell 1.27 #include <Pegasus/Common/Exception.h>
|
49 mike 1.2 #include <Pegasus/Common/Config.h>
50 #include <Pegasus/Common/MessageQueue.h>
51 #include <Pegasus/Common/Pair.h>
52 #include <Pegasus/Common/String.h>
53 #include <Pegasus/Common/Message.h>
|
54 kumpf 1.14 #include <Pegasus/Common/ArrayInternal.h>
|
55 mike 1.2 #include <Pegasus/Common/Monitor.h>
56 #include <Pegasus/Common/AuthenticationInfo.h>
57 #include <Pegasus/Common/TLS.h>
58 #include <Pegasus/Common/HTTPAcceptor.h>
|
59 kumpf 1.13 #include <Pegasus/Common/Linkage.h>
|
60 a.arora 1.25 #include <Pegasus/Common/AutoPtr.h>
|
61 kumpf 1.44 #include <Pegasus/Common/ContentLanguageList.h>
|
62 mike 1.43 #include <Pegasus/Common/Buffer.h>
|
63 mike 1.2
64 PEGASUS_NAMESPACE_BEGIN
65
|
66 mday 1.12 class HTTPConnector;
67
|
68 mday 1.3 class MessageQueueService;
|
69 mday 1.16
|
70 mike 1.2 struct HTTPConnectionRep;
71
72 /** This message is sent from a connection to its owner (so that the
73 owner can do any necessary cleanup).
74 */
75 class CloseConnectionMessage : public Message
76 {
|
77 kumpf 1.39 public:
|
78 mike 1.2
|
79 david.dillard 1.41 CloseConnectionMessage(PEGASUS_SOCKET socket_)
|
80 kumpf 1.39 : Message(CLOSE_CONNECTION_MESSAGE), socket(socket_) { }
|
81 mike 1.2
|
82 david.dillard 1.41 PEGASUS_SOCKET socket;
|
83 mike 1.2 };
84
85 /** This class represents an HTTP listener.
86 */
|
87 mday 1.15 class Monitor;
88
|
89 mday 1.5 class PEGASUS_COMMON_LINKAGE HTTPConnection : public MessageQueue
|
90 mike 1.2 {
|
91 kumpf 1.39 public:
92 typedef MessageQueue Base;
|
93 david.dillard 1.37
|
94 kumpf 1.39 /** Constructor. */
95 HTTPConnection(
|
96 david.dillard 1.38 Monitor* monitor,
97 AutoPtr<MP_Socket>& socket,
98 MessageQueue * ownerMessageQueue,
99 MessageQueue * outputMessageQueue,
100 Boolean exportConnection);
|
101 david.dillard 1.37
|
102 mday 1.4
|
103 kumpf 1.39 /** Destructor. */
104 ~HTTPConnection();
|
105 mday 1.4
|
106 kumpf 1.39 /** This method is called whenever a SocketMessage is enqueued
107 on the input queue of the HTTPConnection object.
108 */
109 virtual void handleEnqueue(Message *);
|
110 brian.campbell 1.30
|
111 kumpf 1.39 virtual void handleEnqueue();
|
112 brian.campbell 1.31
|
113 kumpf 1.39 /** Return socket this connection is using. */
|
114 david.dillard 1.42 PEGASUS_SOCKET getSocket() { return _socket->getSocket();}
|
115 mike 1.2
|
116 kumpf 1.39 MP_Socket& getMPSocket() { return *_socket;}
|
117 mike 1.2
|
118 kumpf 1.39 /** Return the number of outstanding requests for all HTTPConnection
119 instances.
120 */
121 Uint32 getRequestCount();
122
123 Boolean run(Uint32 milliseconds);
124
125 MessageQueue & get_owner(void)
126 {
127 return *_ownerMessageQueue;
128 }
129
130 // was the request for chunking ?
131 Boolean isChunkRequested();
132
133 // ATTN-RK-P1-20020521: This is a major hack, required to get the CIM
134 // server and tests to run successfully. The problem is that the
135 // HTTPAcceptor is deleting an HTTPConnection before all the threads
136 // that are queued up to run in that HTTPConnection instance have had
137 // a chance to finish. This hack makes the HTTPAcceptor spin until
138 // the HTTPConnection event threads have completed, before deleting
139 kumpf 1.39 // the HTTPConnection. Note that this fix is not perfect, because
140 // there is a window between when the HTTPConnection queue lookup is
141 // done and when the refcount is incremented. If the HTTPAcceptor
142 // deletes the HTTPConnection in that window, the soon-to-be-launched
143 // HTTPConnection event thread will fail (hard).
144 AtomicInt refcount;
145
146 CIMException cimException;
147
148 // list of content languages
|
149 kumpf 1.44 ContentLanguageList contentLanguages;
|
150 kumpf 1.39
151 private:
152
153 void _clearIncoming();
154
155 /**
|
156 david.dillard 1.37 @exception Exception Indicates an error occurred.
|
157 kumpf 1.39 */
158 void _getContentLengthAndContentOffset();
|
159 mike 1.2
|
160 kumpf 1.39 void _closeConnection();
|
161 mike 1.2
|
162 kumpf 1.39 void _handleReadEvent();
|
163 mike 1.2
|
164 kumpf 1.39 Boolean _handleWriteEvent(Message &message);
|
165 brian.campbell 1.27
|
166 kumpf 1.46 void _handleReadEventFailure(const String& httpStatusWithDetail,
167 const String& cimError = String());
|
168 kumpf 1.39 void _handleReadEventTransferEncoding();
169 Boolean _isClient();
170
171 Monitor* _monitor;
172
173 AutoPtr<MP_Socket> _socket;
174 MessageQueue* _ownerMessageQueue;
175 MessageQueue* _outputMessageQueue;
176
177 Sint32 _contentOffset;
178 Sint32 _contentLength;
|
179 mike 1.43 Buffer _incomingBuffer;
|
180 kumpf 1.39 AutoPtr<AuthenticationInfo> _authInfo;
181 static AtomicInt _requestCount;
182
183 // _connectionRequestCount contains the number of
184 // requests that have been received on this connection.
185 Uint32 _connectionRequestCount;
186
187 // The _responsePending flag has been added to help
188 // isolate "client connection" problems. When the
189 // HTTPConnection object is created, this flag is
190 // initialized to false. It is set to true when a
191 // request is received on the connection and set to
192 // false when a response is sent. If _responsePending
193 // is true when a close connection request is processed,
194 // a "DISCARDED_DATA" trace entry will be written.
195 Boolean _responsePending;
196
197 Mutex _connection_mut;
198
199 // The _connectionClosePending flag will be set to true if
200 // the connection receives a close connection socket message.
201 kumpf 1.39 // This flag is used to set the connection status to
202 // either Monitor::IDLE (_connectionClosePending == false)
203 // or Monitor::DYING (_connectionClosePending == true) when
204 // returning control of the connection to the Monitor.
205 Boolean _connectionClosePending;
206
|
207 kumpf 1.40 // The _acceptPending flag is set to true if a server-side
208 // connection is accepted but an SSL handshake has not been
209 // completed.
210 Boolean _acceptPending;
211
|
212 kumpf 1.39 int _entry_index;
213
214 // When used by the client, it is an offset (from start of http message)
215 // representing last NON completely parsed chunk of a transfer encoding.
216 // When used by the server, it is the message index that comes down
217 // from the providers/repository representing each message chunk
218 Uint32 _transferEncodingChunkOffset;
219
220 // list of transfer encoding values from sender
221 Array<String> _transferEncodingValues;
222
223 // list of TE values from client
224 Array<String> _transferEncodingTEValues;
225
226 // 2 digit prefix on http header if mpost was used
227 String _mpostPrefix;
228
229 friend class Monitor;
230 friend class HTTPAcceptor;
231 friend class HTTPConnector;
|
232 mike 1.2 };
|
233 mday 1.16
|
234 mike 1.2 PEGASUS_NAMESPACE_END
235
236 #endif /* Pegasus_HTTPConnection_h */
|