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