OW_NAMESPACE::HTTPUtils Namespace Reference


Functions

bool parseHeader (HTTPHeaderMap &map, Array< String > &array, istream &istr)
bool parseHeader (HTTPHeaderMap &map, istream &istr)
bool buildMap (HTTPHeaderMap &map, istream &istr)
String date (void)
 Get the date (for http headers).
String status2String (int code)
 Return a descriptive string associated with a HTTP status code.
String getCounterStr ()
 Returns a two digit sequence for header counting.
String base64Decode (const String &arg)
 Decode Base64 encoded arg
Exceptions:
(Base64FormatException). 

static int char2val (char c)
Array< char > base64Decode (const char *src)
 Decode Base64 encoded arg.
String base64Encode (const String &arg)
 Encode src in Base64
Exceptions:
(Base64FormatException). 

String base64Encode (const char *src)
 Encode src in Base64.
String base64Encode (const UInt8 *src, size_t len)
void DigestCalcHA1 (const String &sAlg, const String &sUserName, const String &sRealm, const String &sPassword, const String &sNonce, const String &sCNonce, String &sSessionKey)
void DigestCalcResponse (const String &sHA1, const String &sNonce, const String &sNonceCount, const String &sCNonce, const String &sQop, const String &sMethod, const String &sDigestUri, const String &sHEntity, String &sResponse)
bool headerHasKey (const HTTPHeaderMap &headers, const String &key)
 Do the headers have a certain key?
String getHeaderValue (const HTTPHeaderMap &headers, const String &key)
 Get a value (based on a key/value pair) from the http headers.
void addHeader (Array< String > &headers, const String &key, const String &value)
 Add a HTTP header.
void eatEntity (istream &istr)
void decodeBasicCreds (const String &info, String &name, String &password)
 Base64Decode a user name/password.
String escapeCharForURL (char c)
 Apply the standard URI [RFC 2396, section 2] escaping mechanism to the char c, using the """ HEX HEX" convention).
 OW_DEFINE_EXCEPTION_WITH_ID (UnescapeCharForURL)
char digitToVal (char c)
char unescapeCharForURL (const char *str)
 Apply the standard URI [RFC 2396, section 2] unescaping mechanism to the String s, formatted in the """ HEX HEX" convention).
String escapeForURL (const String &input)
 Apply the standard URI [RFC 2396, section 2] escaping mechanism to the string input, using the """ HEX HEX" convention).
String unescapeForURL (const String &input)
 Apply the standard URI [RFC 2396, section 2] unescaping mechanism to the string input, using the """ HEX HEX" convention).
OW_HTTP_API bool parseHeader (HTTPHeaderMap &map, Array< String > &array, std::istream &istr)
 Read from an input stream, and fill out a <String, String> map and String Array representing the status line.
OW_HTTP_API bool parseHeader (HTTPHeaderMap &map, std::istream &istr)
 Read from in input stream, parse HTTP headers into a <String, String> map (this is called by parseHeader(map, array, istr)).
OW_HTTP_API void eatEntity (std::istream &istr)
 Read from an input stream, until the end of the entity is reached.
OW_HTTP_API bool buildMap (HTTPHeaderMap &map, std::istream &istr)
 OW_DECLARE_APIEXCEPTION (UnescapeCharForURL, OW_HTTP_API)

Variables

const char *const Header_BypassLocker = "OW_BypassLocker"
const char *const HeaderValue_true = "true"
const char *const HeaderValue_false = "false"
static HTTPCounter theCounter
static const char *const Base64
static const char Pad64 = '='
OW_HTTP_API const char *const Header_BypassLocker
OW_HTTP_API const char *const HeaderValue_true
OW_HTTP_API const char *const HeaderValue_false


Function Documentation

OW_HTTP_API void OW_NAMESPACE::HTTPUtils::addHeader Array< String > &  headers,
const String &  key,
const String &  value
 

Add a HTTP header.

Parameters:
headers a Array<String> containing the outgoing headers.
key the key for the header (left of the ':')
value the value for the header (right of the ':')

Definition at line 656 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::Array< T >::begin(), OW_NAMESPACE::String::empty(), OW_NAMESPACE::Array< T >::end(), OW_NAMESPACE::Array< T >::push_back(), and OW_NAMESPACE::String::trim().

Referenced by OW_NAMESPACE::HTTPSvrConnection::addHeader(), OW_NAMESPACE::HTTPClient::addHeaderCommon(), OW_NAMESPACE::HTTPClient::addHeaderNew(), and OW_NAMESPACE::HTTPClient::addHeaderPersistent().

OW_HTTP_API Array< char > OW_NAMESPACE::HTTPUtils::base64Decode const char *  src  ) 
 

Decode Base64 encoded arg.

Parameters:
src NULL-terminated string to be encoded
Exceptions:
(Base64FormatException) 

Definition at line 347 of file OW_HTTPUtils.cpp.

References ch, char2val(), OW_NAMESPACE::AutoPtrVec< X >::get(), OW_THROW, and state.

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::base64Decode const String &  arg  ) 
 

Decode Base64 encoded arg

Exceptions:
(Base64FormatException). 

Definition at line 270 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::String::c_str().

Referenced by decodeBasicCreds().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::base64Encode const UInt8 src,
size_t  len
 

Parameters:
src pointer to data to be encoded. The data may contain any value, including 0.
len The length of the data to be encoded.
Exceptions:
(Base64FormatException) 

Definition at line 485 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::AutoPtrVec< X >::get(), i, and OW_THROW.

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::base64Encode const char *  src  ) 
 

Encode src in Base64.

Parameters:
src NULL-terminated string to be encoded
Exceptions:
(Base64FormatException) 

Definition at line 479 of file OW_HTTPUtils.cpp.

References base64Encode().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::base64Encode const String &  arg  ) 
 

Encode src in Base64

Exceptions:
(Base64FormatException). 

Definition at line 474 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::String::c_str(), and OW_NAMESPACE::String::length().

Referenced by base64Encode(), and OW_NAMESPACE::HTTPClient::sendAuthorization().

OW_HTTP_API bool OW_NAMESPACE::HTTPUtils::buildMap HTTPHeaderMap map,
std::istream &  istr
 

bool OW_NAMESPACE::HTTPUtils::buildMap HTTPHeaderMap map,
istream &  istr
 

Definition at line 99 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::String::getLine(), OW_NAMESPACE::String::isSpaces(), OW_NAMESPACE::String::length(), OW_NAMESPACE::String::ltrim(), and OW_NAMESPACE::String::rtrim().

Referenced by parseHeader().

static int OW_NAMESPACE::HTTPUtils::char2val char  c  )  [static]
 

Definition at line 275 of file OW_HTTPUtils.cpp.

Referenced by base64Decode().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::date void   ) 
 

Get the date (for http headers).

Returns:
a String representing the current date/time

Definition at line 148 of file OW_HTTPUtils.cpp.

References OW_THROW, OW_NAMESPACE::DateTime::setToCurrent(), OW_NAMESPACE::Array< T >::size(), OW_NAMESPACE::String::tokenize(), and OW_NAMESPACE::DateTime::toString().

Referenced by OW_NAMESPACE::HTTPSvrConnection::run().

OW_HTTP_API void OW_NAMESPACE::HTTPUtils::decodeBasicCreds const String &  info,
String &  name,
String &  password
 

Base64Decode a user name/password.

Parameters:
info a base64 encoded representation of a "<name>:<password>" string
name The name gets assigned here.
password the password gets assigned here.

Definition at line 684 of file OW_HTTPUtils.cpp.

References base64Decode(), OW_NAMESPACE::String::indexOf(), name, OW_THROW, and OW_NAMESPACE::String::substring().

OW_HTTP_API void OW_NAMESPACE::HTTPUtils::DigestCalcHA1 const String &  sAlg,
const String &  sUserName,
const String &  sRealm,
const String &  sPassword,
const String &  sNonce,
const String &  sCNonce,
String &  sSessionKey
 

Definition at line 547 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::String::equalsIgnoreCase(), OW_NAMESPACE::MD5::getDigest(), OW_NAMESPACE::MD5HASHLEN, OW_NAMESPACE::String::toString(), OW_NAMESPACE::MD5::toString(), and OW_NAMESPACE::MD5::update().

OW_HTTP_API void OW_NAMESPACE::HTTPUtils::DigestCalcResponse const String &  sHA1,
const String &  sNonce,
const String &  sNonceCount,
const String &  sCNonce,
const String &  sQop,
const String &  sMethod,
const String &  sDigestUri,
const String &  sHEntity,
String &  sResponse
 

Definition at line 578 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::String::equalsIgnoreCase(), and OW_NAMESPACE::MD5::update().

Referenced by OW_NAMESPACE::HTTPClient::sendAuthorization().

char OW_NAMESPACE::HTTPUtils::@0::digitToVal char  c  )  [inline, static]
 

Definition at line 731 of file OW_HTTPUtils.cpp.

Referenced by unescapeCharForURL().

OW_HTTP_API void OW_NAMESPACE::HTTPUtils::eatEntity std::istream &  istr  ) 
 

Read from an input stream, until the end of the entity is reached.

This is usefull when using a HTTPChunkedIStream or HTTPLenLimitIStream, and the XML parser (for instance), may not have read to the end of the entity.

Parameters:
istr A istream& containing the entity (presumably a HTTPChunkedIStream, HTTPLenLimitIStream, or TempFileStream)

void OW_NAMESPACE::HTTPUtils::eatEntity istream &  istr  ) 
 

Definition at line 676 of file OW_HTTPUtils.cpp.

Referenced by OW_NAMESPACE::HTTPSvrConnection::cleanUpIStreams(), OW_NAMESPACE::HTTPClient::cleanUpIStreams(), OW_NAMESPACE::CIMXMLCIMOMHandle::doSendRequest(), and OW_NAMESPACE::HTTPClient::prepareForRetry().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::escapeCharForURL char  c  ) 
 

Apply the standard URI [RFC 2396, section 2] escaping mechanism to the char c, using the """ HEX HEX" convention).

Parameters:
c The char to escape
Returns:
The escaped char

Definition at line 716 of file OW_HTTPUtils.cpp.

Referenced by escapeForURL().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::escapeForURL const String &  input  ) 
 

Apply the standard URI [RFC 2396, section 2] escaping mechanism to the string input, using the """ HEX HEX" convention).

Parameters:
input The string to escape
Returns:
The escaped string

Definition at line 748 of file OW_HTTPUtils.cpp.

References escapeCharForURL(), i, and OW_NAMESPACE::String::length().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::getCounterStr  ) 
 

Returns a two digit sequence for header counting.

Returns:
String containing a two digit number

Definition at line 251 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::HTTPCounter::getNextCounter(), and theCounter.

Referenced by OW_NAMESPACE::HTTPSvrConnection::beginPostResponse(), OW_NAMESPACE::HTTPSvrConnection::options(), and OW_NAMESPACE::HTTPClient::sendDataToServer().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::getHeaderValue const HTTPHeaderMap headers,
const String &  key
 

Get a value (based on a key/value pair) from the http headers.

Parameters:
headers A Map<String, String> containing the headers.
key The key to look for.
Returns:
the value associated with the key

Definition at line 640 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::Map< Key, T, Compare >::end(), OW_NAMESPACE::Map< Key, T, Compare >::find(), i, OW_NAMESPACE::String::toLowerCase(), and OW_NAMESPACE::String::toString().

Referenced by OW_NAMESPACE::HTTPSvrConnection::getHeaderValue(), OW_NAMESPACE::HTTPClient::getHeaderValue(), OW_NAMESPACE::CIMXMLCIMOMHandle::getHTTPResponseHeader(), OW_NAMESPACE::BinaryCIMOMHandle::getHTTPResponseHeader(), and OW_NAMESPACE::HTTPClient::getResponseHeader().

OW_HTTP_API bool OW_NAMESPACE::HTTPUtils::headerHasKey const HTTPHeaderMap headers,
const String &  key
 

Do the headers have a certain key?

Parameters:
headers A Map<String, String> containing the headers
key the key to look for.
Returns:
true if the headers contain the key

Definition at line 624 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::Map< Key, T, Compare >::end(), OW_NAMESPACE::Map< Key, T, Compare >::find(), i, OW_NAMESPACE::String::toLowerCase(), and OW_NAMESPACE::String::toString().

Referenced by OW_NAMESPACE::CIMXMLCIMOMHandle::getHTTPResponseHeader(), OW_NAMESPACE::BinaryCIMOMHandle::getHTTPResponseHeader(), OW_NAMESPACE::HTTPClient::getResponseHeader(), OW_NAMESPACE::HTTPSvrConnection::headerHasKey(), and OW_NAMESPACE::HTTPClient::headerHasKey().

OW_NAMESPACE::HTTPUtils::OW_DECLARE_APIEXCEPTION UnescapeCharForURL  ,
OW_HTTP_API 
 

OW_NAMESPACE::HTTPUtils::OW_DEFINE_EXCEPTION_WITH_ID UnescapeCharForURL   ) 
 

OW_HTTP_API bool OW_NAMESPACE::HTTPUtils::parseHeader HTTPHeaderMap map,
std::istream &  istr
 

Read from in input stream, parse HTTP headers into a <String, String> map (this is called by parseHeader(map, array, istr)).

Parameters:
map A <String, String> map to be filled out.
istr A istream& to read the headers from
Returns:
true if no errors occurred, false if an error occurred.

OW_HTTP_API bool OW_NAMESPACE::HTTPUtils::parseHeader HTTPHeaderMap map,
Array< String > &  array,
std::istream &  istr
 

Read from an input stream, and fill out a <String, String> map and String Array representing the status line.

Parameters:
map a <String, String> map to fill out
array A String array to be filled out, representing the status line
istr A istream& to read the headers from
Returns:
true if no errors occurred, false if an error occurred.

bool OW_NAMESPACE::HTTPUtils::parseHeader HTTPHeaderMap map,
istream &  istr
 

Definition at line 93 of file OW_HTTPUtils.cpp.

References buildMap().

bool OW_NAMESPACE::HTTPUtils::parseHeader HTTPHeaderMap map,
Array< String > &  array,
istream &  istr
 

Definition at line 74 of file OW_HTTPUtils.cpp.

References buildMap(), OW_NAMESPACE::String::getLine(), OW_NAMESPACE::String::isSpaces(), and OW_NAMESPACE::String::tokenize().

Referenced by OW_NAMESPACE::HTTPChunkedIStream::buildTrailerMap(), OW_NAMESPACE::HTTPClient::checkResponse(), and OW_NAMESPACE::HTTPSvrConnection::run().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::status2String int  code  ) 
 

Return a descriptive string associated with a HTTP status code.

Parameters:
code the status code to interpret.
Returns:
a String represetation of code

Definition at line 163 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::SC_ACCEPTED, OW_NAMESPACE::SC_BAD_GATEWAY, OW_NAMESPACE::SC_BAD_REQUEST, OW_NAMESPACE::SC_CONFLICT, OW_NAMESPACE::SC_CONTINUE, OW_NAMESPACE::SC_CREATED, OW_NAMESPACE::SC_FORBIDDEN, OW_NAMESPACE::SC_GATEWAY_TIMEOUT, OW_NAMESPACE::SC_GONE, OW_NAMESPACE::SC_HTTP_VERSION_NOT_SUPPORTED, OW_NAMESPACE::SC_INTERNAL_SERVER_ERROR, OW_NAMESPACE::SC_LENGTH_REQUIRED, OW_NAMESPACE::SC_METHOD_NOT_ALLOWED, OW_NAMESPACE::SC_MOVED_PERMANENTLY, OW_NAMESPACE::SC_MOVED_TEMPORARILY, OW_NAMESPACE::SC_MULTIPLE_CHOICES, OW_NAMESPACE::SC_NO_CONTENT, OW_NAMESPACE::SC_NON_AUTHORITATIVE_INFORMATION, OW_NAMESPACE::SC_NOT_ACCEPTABLE, OW_NAMESPACE::SC_NOT_EXTENDED, OW_NAMESPACE::SC_NOT_FOUND, OW_NAMESPACE::SC_NOT_IMPLEMENTED, OW_NAMESPACE::SC_NOT_MODIFIED, OW_NAMESPACE::SC_OK, OW_NAMESPACE::SC_PARTIAL_CONTENT, OW_NAMESPACE::SC_PAYMENT_REQUIRED, OW_NAMESPACE::SC_PRECONDITION_FAILED, OW_NAMESPACE::SC_PROXY_AUTHENTICATION_REQUIRED, OW_NAMESPACE::SC_REQUEST_ENTITY_TOO_LARGE, OW_NAMESPACE::SC_REQUEST_TIMEOUT, OW_NAMESPACE::SC_REQUEST_URI_TOO_LONG, OW_NAMESPACE::SC_RESET_CONTENT, OW_NAMESPACE::SC_SEE_OTHER, OW_NAMESPACE::SC_SERVICE_UNAVAILABLE, OW_NAMESPACE::SC_SWITCHING_PROTOCOLS, OW_NAMESPACE::SC_UNAUTHORIZED, OW_NAMESPACE::SC_UNSUPPORTED_MEDIA_TYPE, and OW_NAMESPACE::SC_USE_PROXY.

Referenced by OW_NAMESPACE::HTTPSvrConnection::sendHeaders().

OW_HTTP_API char OW_NAMESPACE::HTTPUtils::unescapeCharForURL const char *  str  ) 
 

Apply the standard URI [RFC 2396, section 2] unescaping mechanism to the String s, formatted in the """ HEX HEX" convention).

Parameters:
str The string to unescape. Only the first 3 characters are considered. Following characters are ignored.
Returns:
The unescaped char
Exceptions:
unEscapeCharForURLException If the string doesn't contain a valid escape sequence

Definition at line 738 of file OW_HTTPUtils.cpp.

References digitToVal(), and OW_THROW.

Referenced by unescapeForURL().

OW_HTTP_API String OW_NAMESPACE::HTTPUtils::unescapeForURL const String &  input  ) 
 

Apply the standard URI [RFC 2396, section 2] unescaping mechanism to the string input, using the """ HEX HEX" convention).

Parameters:
input The string to unescape
Returns:
The unescaped string

Definition at line 782 of file OW_HTTPUtils.cpp.

References OW_NAMESPACE::String::c_str(), OW_NAMESPACE::String::length(), and unescapeCharForURL().


Variable Documentation

const char* const OW_NAMESPACE::HTTPUtils::Base64 [static]
 

Initial value:

   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Definition at line 266 of file OW_HTTPUtils.cpp.

OW_HTTP_API const char* const OW_NAMESPACE::HTTPUtils::Header_BypassLocker
 

Definition at line 69 of file OW_HTTPUtils.cpp.

const char* const OW_NAMESPACE::HTTPUtils::Header_BypassLocker = "OW_BypassLocker"
 

Definition at line 69 of file OW_HTTPUtils.cpp.

OW_HTTP_API const char* const OW_NAMESPACE::HTTPUtils::HeaderValue_false
 

Definition at line 71 of file OW_HTTPUtils.cpp.

const char* const OW_NAMESPACE::HTTPUtils::HeaderValue_false = "false"
 

Definition at line 71 of file OW_HTTPUtils.cpp.

OW_HTTP_API const char* const OW_NAMESPACE::HTTPUtils::HeaderValue_true
 

Definition at line 70 of file OW_HTTPUtils.cpp.

const char* const OW_NAMESPACE::HTTPUtils::HeaderValue_true = "true"
 

Definition at line 70 of file OW_HTTPUtils.cpp.

const char OW_NAMESPACE::HTTPUtils::Pad64 = '=' [static]
 

Definition at line 268 of file OW_HTTPUtils.cpp.

HTTPCounter OW_NAMESPACE::HTTPUtils::theCounter [static]
 

Definition at line 248 of file OW_HTTPUtils.cpp.

Referenced by getCounterStr().


Generated on Thu Feb 9 09:17:13 2006 for openwbem by  doxygen 1.4.6