OW_NAMESPACE::HTTPSvrConnection Class Reference

#include <OW_HTTPSvrConnection.hpp>

Inheritance diagram for OW_NAMESPACE::HTTPSvrConnection:

Inheritance graph
[legend]
Collaboration diagram for OW_NAMESPACE::HTTPSvrConnection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 HTTPSvrConnection (const Socket &socket, HTTPServer *htin, UnnamedPipeRef &upipe, const HTTPServer::Options &opts)
 Start a new http server connection.
 ~HTTPSvrConnection ()
virtual void run ()
 start processing the connection
bool headerHasKey (const String &key) const
 Do the request headers contain a specific key?
String getHeaderValue (const String &key) const
 Get the value associated with a key in the request headers.
void addHeader (const String &key, const String &value)
 Add a header to the response headers.
StringArray getRequestLine () const
 Get the request status line example: POST /cimom HTTP/1.1.
void setErrorDetails (const String &details)
String getHostName ()
 Get the hostname of the server.

Private Types

enum  requestMethod_t {
  BAD = 0, POST, M_POST, TRACE,
  OPTIONS
}
enum  httpVerFlag_t { HTTP_VER_BAD = 0, HTTP_VER_10, HTTP_VER_11 }

Private Member Functions

int processRequestLine ()
int processHeaders (OperationContext &context)
void trace ()
void options (OperationContext &context)
void post (std::istream &istr, OperationContext &context)
void sendError (int resCode)
void beginPostResponse ()
void initRespStream (std::ostream *&ostrEntity)
void sendPostResponse (std::ostream *ostrEntity, TempFileStream &ostrError, OperationContext &context)
int performAuthentication (const String &info, OperationContext &context)
void sendHeaders (int sc, int len=-1)
void cleanUpIStreams (const CIMProtocolIStreamIFCRef &istrm)
CIMProtocolIStreamIFCRef convertToFiniteStream (std::istream &istr)
String getContentLanguage (OperationContext &context, bool &setByProvider, bool &clientSpecified)
void doCooperativeCancel ()
 This function is available for subclasses to override if they wish to be notified when a cooperative cancel is being invoked on the thread.

Private Attributes

StringArray m_requestLine
HTTPHeaderMap m_requestHeaders
HTTPServerm_pHTTPServer
std::istream * m_pIn
std::ofstream m_tempFile
Socket m_socket
std::ostream & m_ostr
int m_resCode
bool m_needSendError
Array< Stringm_responseHeaders
httpVerFlag_t m_httpVersion
requestMethod_t m_method
std::istream & m_istr
bool m_isClose
Int64 m_contentLength
bool m_chunkedIn
bool m_deflateCompressionIn
bool m_deflateCompressionOut
String m_errDetails
String m_reqHeaderPrefix
String m_respHeaderPrefix
bool m_isAuthenticated
IntrusiveReference< UnnamedPipem_upipe
bool m_chunkedOut
String m_userName
bool m_clientIsOpenWBEM2
RequestHandlerIFCRef m_requestHandler
HTTPServer::Options m_options
bool m_shutdown
Reference< HTTPChunkedOStreamm_HTTPChunkedOStreamRef
Reference< TempFileStreamm_TempFileStreamRef

Detailed Description

Definition at line 58 of file OW_HTTPSvrConnection.hpp.


Member Enumeration Documentation

enum OW_NAMESPACE::HTTPSvrConnection::httpVerFlag_t [private]
 

Enumerator:
HTTP_VER_BAD 
HTTP_VER_10 
HTTP_VER_11 

Definition at line 157 of file OW_HTTPSvrConnection.hpp.

enum OW_NAMESPACE::HTTPSvrConnection::requestMethod_t [private]
 

Enumerator:
BAD 
POST 
M_POST 
TRACE 
OPTIONS 

Definition at line 149 of file OW_HTTPSvrConnection.hpp.


Constructor & Destructor Documentation

OW_NAMESPACE::HTTPSvrConnection::HTTPSvrConnection const Socket socket,
HTTPServer htin,
UnnamedPipeRef upipe,
const HTTPServer::Options opts
 

Start a new http server connection.

This is called after HTTPServer accepts the connection.

Parameters:
socket the socket (just accepted)
htin a pointer to the HTTPServer
upipe a pipe to receive a shutdown signal from
opts The configuration options struct (see HTTPServer.hpp)

OW_NAMESPACE::HTTPSvrConnection::~HTTPSvrConnection  ) 
 

Definition at line 139 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::Socket::disconnect(), and m_socket.


Member Function Documentation

void OW_NAMESPACE::HTTPSvrConnection::addHeader const String key,
const String value
[inline]
 

Add a header to the response headers.

Parameters:
key the key of the header (left of the ':')
value the value (right of the ':')

Definition at line 115 of file OW_HTTPSvrConnection.hpp.

References OW_NAMESPACE::HTTPUtils::addHeader().

Referenced by OW_NAMESPACE::DigestAuthentication::authenticate(), beginPostResponse(), options(), run(), sendHeaders(), and trace().

void OW_NAMESPACE::HTTPSvrConnection::beginPostResponse  )  [private]
 

Definition at line 384 of file OW_HTTPSvrConnection.cpp.

References addHeader(), OW_NAMESPACE::HTTPUtils::getCounterStr(), m_chunkedOut, m_clientIsOpenWBEM2, m_deflateCompressionOut, m_method, M_POST, m_requestHandler, m_resCode, m_respHeaderPrefix, and sendHeaders().

void OW_NAMESPACE::HTTPSvrConnection::cleanUpIStreams const CIMProtocolIStreamIFCRef istrm  )  [private]
 

Definition at line 376 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::HTTPUtils::eatEntity().

Referenced by run().

CIMProtocolIStreamIFCRef OW_NAMESPACE::HTTPSvrConnection::convertToFiniteStream std::istream &  istr  )  [private]
 

Referenced by run().

void OW_NAMESPACE::HTTPSvrConnection::doCooperativeCancel  )  [private, virtual]
 

This function is available for subclasses to override if they wish to be notified when a cooperative cancel is being invoked on the thread.

Note that this function will be invoked in a separate thread. For instance, a thread may use this function to write to a pipe or socket, if Thread::run() is blocked in select(), it can be unblocked and instructed to exit.

It is also possible for an individual thread to override the cancellation request, if it knows that cancellation at this time may crash the system or cause a deadlock. To do this, the thread should throw an CancellationDeniedException. Note that threads are usually only cancelled in the event of a system shutdown or restart, so a thread should make a best effort to actually shutdown.

Exceptions:
CancellationDeniedException 

Reimplemented from OW_NAMESPACE::Runnable.

Definition at line 1292 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::Socket::disconnect(), m_shutdown, and m_socket.

String OW_NAMESPACE::HTTPSvrConnection::getContentLanguage OperationContext context,
bool &  setByProvider,
bool &  clientSpecified
[private]
 

Definition at line 1256 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::IntrusiveReference< T >::cast_to(), context, OW_NAMESPACE::HTTPServer::Options::defaultContentLanguage, OW_NAMESPACE::OperationContext::getData(), m_options, and OW_NAMESPACE::OperationContext::SESSION_LANGUAGE_KEY.

String OW_NAMESPACE::HTTPSvrConnection::getHeaderValue const String key  )  const [inline]
 

Get the value associated with a key in the request headers.

Parameters:
key the key to look up
Returns:
the value associated with the key in the request headers.

Definition at line 106 of file OW_HTTPSvrConnection.hpp.

References OW_NAMESPACE::HTTPUtils::getHeaderValue().

Referenced by processHeaders().

String OW_NAMESPACE::HTTPSvrConnection::getHostName  ) 
 

Get the hostname of the server.

Definition at line 1220 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::SocketAddress::getAnyLocalHost(), and OW_NAMESPACE::SocketAddress::getName().

Referenced by OW_NAMESPACE::DigestAuthentication::authenticate().

StringArray OW_NAMESPACE::HTTPSvrConnection::getRequestLine  )  const [inline]
 

Get the request status line example: POST /cimom HTTP/1.1.

Returns:
a string array containing the tokenized request status line.

Definition at line 124 of file OW_HTTPSvrConnection.hpp.

bool OW_NAMESPACE::HTTPSvrConnection::headerHasKey const String key  )  const [inline]
 

Do the request headers contain a specific key?

Parameters:
key the key to look for
Returns:
true if the key is found in the request headers.

Definition at line 97 of file OW_HTTPSvrConnection.hpp.

References OW_NAMESPACE::HTTPUtils::headerHasKey().

Referenced by processHeaders().

void OW_NAMESPACE::HTTPSvrConnection::initRespStream std::ostream *&  ostrEntity  )  [private]
 

void OW_NAMESPACE::HTTPSvrConnection::options OperationContext context  )  [private]
 

Definition at line 1065 of file OW_HTTPSvrConnection.cpp.

References addHeader(), OW_NAMESPACE::CIMFeatures::cimProduct, context, OW_NAMESPACE::HTTPServer::Options::enableDeflate, OW_NAMESPACE::HTTPServer::Options::env, OW_NAMESPACE::CIMFeatures::extURL, OW_NAMESPACE::HTTPUtils::getCounterStr(), i, OW_NAMESPACE::CIMFeatures::LISTENER, m_options, m_requestHandler, OW_ASSERT, OW_HTTP_THROW, OW_NAMESPACE::CIMFeatures::protocolVersion, OW_NAMESPACE::SC_NOT_IMPLEMENTED, OW_NAMESPACE::CIMFeatures::SERVER, OW_NAMESPACE::Array< T >::size(), OW_NAMESPACE::CIMFeatures::supportedGroups, and OW_NAMESPACE::CIMFeatures::supportsBatch.

Referenced by run().

int OW_NAMESPACE::HTTPSvrConnection::performAuthentication const String info,
OperationContext context
[private]
 

Definition at line 1190 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::HTTPServer::authenticate(), context, m_pHTTPServer, m_socket, m_userName, and OW_NAMESPACE::SC_OK.

Referenced by processHeaders().

void OW_NAMESPACE::HTTPSvrConnection::post std::istream &  istr,
OperationContext context
[private]
 

Referenced by run().

int OW_NAMESPACE::HTTPSvrConnection::processHeaders OperationContext context  )  [private]
 

Definition at line 681 of file OW_HTTPSvrConnection.cpp.

References OW_NAMESPACE::HTTPServer::Options::allowAnonymous, context, OW_NAMESPACE::String::empty(), getHeaderValue(), headerHasKey(), HTTP_VER_11, m_chunkedIn, m_contentLength, m_errDetails, m_httpVersion, m_isAuthenticated, m_isClose, m_method, m_options, M_POST, m_userName, performAuthentication(), POST, OW_NAMESPACE::SC_BAD_REQUEST, OW_NAMESPACE::SC_INTERNAL_SERVER_ERROR, OW_NAMESPACE::SC_LENGTH_REQUIRED, OW_NAMESPACE::SC_UNAUTHORIZED, OW_NAMESPACE::OperationContext::setStringData(), OW_NAMESPACE::String::toInt64(), TRACE, and OW_NAMESPACE::OperationContext::USER_NAME.

Referenced by run().

int OW_NAMESPACE::HTTPSvrConnection::processRequestLine  )  [private]
 

Definition at line 614 of file OW_HTTPSvrConnection.cpp.

References HTTP_VER_10, HTTP_VER_11, HTTP_VER_BAD, m_errDetails, m_httpVersion, m_requestLine, OW_NAMESPACE::SC_BAD_REQUEST, OW_NAMESPACE::SC_HTTP_VERSION_NOT_SUPPORTED, and OW_NAMESPACE::Array< T >::size().

Referenced by run().

void OW_NAMESPACE::HTTPSvrConnection::run  )  [virtual]
 

start processing the connection

Implements OW_NAMESPACE::Runnable.

Definition at line 152 of file OW_HTTPSvrConnection.cpp.

References addHeader(), cleanUpIStreams(), OW_NAMESPACE::Map< Key, T, Compare >::clear(), OW_NAMESPACE::Array< T >::clear(), OW_NAMESPACE::OperationContext::CLIENT_IPADDR, context, convertToFiniteStream(), OW_NAMESPACE::HTTPUtils::date(), OW_NAMESPACE::String::erase(), OW_NAMESPACE::Socket::getPeerAddress(), OW_NAMESPACE::Socket::getSelectObj(), OW_NAMESPACE::OperationContext::HTTP_PATH, m_chunkedIn, m_contentLength, m_errDetails, m_isAuthenticated, m_isClose, m_istr, m_method, m_needSendError, m_options, m_ostr, M_POST, m_reqHeaderPrefix, m_requestHeaders, m_requestLine, m_resCode, m_responseHeaders, m_shutdown, m_socket, m_upipe, options(), OPTIONS, OW_THROW, OW_NAMESPACE::HTTPUtils::parseHeader(), post(), POST, processHeaders(), processRequestLine(), OW_NAMESPACE::Array< T >::push_back(), OW_NAMESPACE::SC_BAD_REQUEST, OW_NAMESPACE::SC_INTERNAL_SERVER_ERROR, OW_NAMESPACE::SC_OK, OW_NAMESPACE::SC_REQUEST_TIMEOUT, OW_NAMESPACE::SC_SERVICE_UNAVAILABLE, OW_NAMESPACE::Select::select(), OW_NAMESPACE::Select::SELECT_ERROR, OW_NAMESPACE::Select::SELECT_INTERRUPTED, OW_NAMESPACE::Select::SELECT_TIMEOUT, sendError(), OW_NAMESPACE::OperationContext::setStringData(), OW_NAMESPACE::HTTPServer::Options::timeout, OW_NAMESPACE::SocketAddress::toString(), trace(), and TRACE.

void OW_NAMESPACE::HTTPSvrConnection::sendError int  resCode  )  [private]
 

Definition at line 1145 of file OW_HTTPSvrConnection.cpp.

References m_errDetails, m_ostr, m_socket, OW_NAMESPACE::Socket::receiveTimeOutExpired(), and OW_NAMESPACE::SC_REQUEST_TIMEOUT.

Referenced by run().

void OW_NAMESPACE::HTTPSvrConnection::sendHeaders int  sc,
int  len = -1
[private]
 

Definition at line 1203 of file OW_HTTPSvrConnection.cpp.

References addHeader(), i, m_ostr, m_responseHeaders, OW_NAMESPACE::Array< T >::size(), and OW_NAMESPACE::HTTPUtils::status2String().

Referenced by beginPostResponse(), and trace().

void OW_NAMESPACE::HTTPSvrConnection::sendPostResponse std::ostream *  ostrEntity,
TempFileStream ostrError,
OperationContext context
[private]
 

void OW_NAMESPACE::HTTPSvrConnection::setErrorDetails const String details  )  [inline]
 

Definition at line 135 of file OW_HTTPSvrConnection.hpp.

Referenced by OW_NAMESPACE::LocalAuthentication::authenticate(), and OW_NAMESPACE::DigestAuthentication::authenticate().

void OW_NAMESPACE::HTTPSvrConnection::trace  )  [private]
 

Definition at line 1029 of file OW_HTTPSvrConnection.cpp.

References addHeader(), i, m_ostr, m_requestLine, m_resCode, ostr, sendHeaders(), and OW_NAMESPACE::Array< T >::size().

Referenced by run().


Member Data Documentation

bool OW_NAMESPACE::HTTPSvrConnection::m_chunkedIn [private]
 

Definition at line 178 of file OW_HTTPSvrConnection.hpp.

Referenced by processHeaders(), and run().

bool OW_NAMESPACE::HTTPSvrConnection::m_chunkedOut [private]
 

Definition at line 190 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse().

bool OW_NAMESPACE::HTTPSvrConnection::m_clientIsOpenWBEM2 [private]
 

Definition at line 192 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse().

Int64 OW_NAMESPACE::HTTPSvrConnection::m_contentLength [private]
 

Definition at line 177 of file OW_HTTPSvrConnection.hpp.

Referenced by processHeaders(), and run().

bool OW_NAMESPACE::HTTPSvrConnection::m_deflateCompressionIn [private]
 

Definition at line 179 of file OW_HTTPSvrConnection.hpp.

bool OW_NAMESPACE::HTTPSvrConnection::m_deflateCompressionOut [private]
 

Definition at line 180 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse().

String OW_NAMESPACE::HTTPSvrConnection::m_errDetails [private]
 

Definition at line 181 of file OW_HTTPSvrConnection.hpp.

Referenced by processHeaders(), processRequestLine(), run(), and sendError().

Reference<HTTPChunkedOStream> OW_NAMESPACE::HTTPSvrConnection::m_HTTPChunkedOStreamRef [private]
 

Definition at line 200 of file OW_HTTPSvrConnection.hpp.

httpVerFlag_t OW_NAMESPACE::HTTPSvrConnection::m_httpVersion [private]
 

Definition at line 173 of file OW_HTTPSvrConnection.hpp.

Referenced by processHeaders(), and processRequestLine().

bool OW_NAMESPACE::HTTPSvrConnection::m_isAuthenticated [private]
 

Definition at line 184 of file OW_HTTPSvrConnection.hpp.

Referenced by processHeaders(), and run().

bool OW_NAMESPACE::HTTPSvrConnection::m_isClose [private]
 

Definition at line 176 of file OW_HTTPSvrConnection.hpp.

Referenced by processHeaders(), and run().

std::istream& OW_NAMESPACE::HTTPSvrConnection::m_istr [private]
 

Definition at line 175 of file OW_HTTPSvrConnection.hpp.

Referenced by run().

requestMethod_t OW_NAMESPACE::HTTPSvrConnection::m_method [private]
 

Definition at line 174 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse(), processHeaders(), and run().

bool OW_NAMESPACE::HTTPSvrConnection::m_needSendError [private]
 

Definition at line 171 of file OW_HTTPSvrConnection.hpp.

Referenced by run().

HTTPServer::Options OW_NAMESPACE::HTTPSvrConnection::m_options [private]
 

Definition at line 195 of file OW_HTTPSvrConnection.hpp.

Referenced by getContentLanguage(), options(), processHeaders(), and run().

std::ostream& OW_NAMESPACE::HTTPSvrConnection::m_ostr [private]
 

Definition at line 169 of file OW_HTTPSvrConnection.hpp.

Referenced by run(), sendError(), sendHeaders(), and trace().

HTTPServer* OW_NAMESPACE::HTTPSvrConnection::m_pHTTPServer [private]
 

Definition at line 165 of file OW_HTTPSvrConnection.hpp.

Referenced by performAuthentication().

std::istream* OW_NAMESPACE::HTTPSvrConnection::m_pIn [private]
 

Definition at line 166 of file OW_HTTPSvrConnection.hpp.

String OW_NAMESPACE::HTTPSvrConnection::m_reqHeaderPrefix [private]
 

Definition at line 182 of file OW_HTTPSvrConnection.hpp.

Referenced by run().

RequestHandlerIFCRef OW_NAMESPACE::HTTPSvrConnection::m_requestHandler [private]
 

Definition at line 194 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse(), and options().

HTTPHeaderMap OW_NAMESPACE::HTTPSvrConnection::m_requestHeaders [private]
 

Definition at line 164 of file OW_HTTPSvrConnection.hpp.

Referenced by run().

StringArray OW_NAMESPACE::HTTPSvrConnection::m_requestLine [private]
 

Definition at line 163 of file OW_HTTPSvrConnection.hpp.

Referenced by processRequestLine(), run(), and trace().

int OW_NAMESPACE::HTTPSvrConnection::m_resCode [private]
 

Definition at line 170 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse(), run(), and trace().

String OW_NAMESPACE::HTTPSvrConnection::m_respHeaderPrefix [private]
 

Definition at line 183 of file OW_HTTPSvrConnection.hpp.

Referenced by beginPostResponse().

Array<String> OW_NAMESPACE::HTTPSvrConnection::m_responseHeaders [private]
 

Definition at line 172 of file OW_HTTPSvrConnection.hpp.

Referenced by run(), and sendHeaders().

bool OW_NAMESPACE::HTTPSvrConnection::m_shutdown [private]
 

Definition at line 196 of file OW_HTTPSvrConnection.hpp.

Referenced by doCooperativeCancel(), and run().

Socket OW_NAMESPACE::HTTPSvrConnection::m_socket [private]
 

Definition at line 168 of file OW_HTTPSvrConnection.hpp.

Referenced by doCooperativeCancel(), performAuthentication(), run(), sendError(), and ~HTTPSvrConnection().

std::ofstream OW_NAMESPACE::HTTPSvrConnection::m_tempFile [private]
 

Definition at line 167 of file OW_HTTPSvrConnection.hpp.

Reference<TempFileStream> OW_NAMESPACE::HTTPSvrConnection::m_TempFileStreamRef [private]
 

Definition at line 205 of file OW_HTTPSvrConnection.hpp.

IntrusiveReference<UnnamedPipe> OW_NAMESPACE::HTTPSvrConnection::m_upipe [private]
 

Definition at line 188 of file OW_HTTPSvrConnection.hpp.

Referenced by run().

String OW_NAMESPACE::HTTPSvrConnection::m_userName [private]
 

Definition at line 191 of file OW_HTTPSvrConnection.hpp.

Referenced by performAuthentication(), and processHeaders().


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:16:53 2006 for openwbem by  doxygen 1.4.6