OW_HTTPUtils.hpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
00003 *
00004 * Redistribution and use in source and binary forms, with or without
00005 * modification, are permitted provided that the following conditions are met:
00006 *
00007 *  - Redistributions of source code must retain the above copyright notice,
00008 *    this list of conditions and the following disclaimer.
00009 *
00010 *  - Redistributions in binary form must reproduce the above copyright notice,
00011 *    this list of conditions and the following disclaimer in the documentation
00012 *    and/or other materials provided with the distribution.
00013 *
00014 *  - Neither the name of Vintela, Inc. nor the names of its
00015 *    contributors may be used to endorse or promote products derived from this
00016 *    software without specific prior written permission.
00017 *
00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
00019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
00022 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00028 * POSSIBILITY OF SUCH DAMAGE.
00029 *******************************************************************************/
00030 
00036 #ifndef OW_HTTPUTILS_HPP_
00037 #define OW_HTTPUTILS_HPP_
00038 #include "OW_config.h"
00039 #include "OW_Array.hpp"
00040 #include "OW_Map.hpp"
00041 #include "OW_String.hpp"
00042 #include "OW_Base64FormatException.hpp"
00043 #include <iosfwd>
00044 
00045 namespace OW_NAMESPACE
00046 {
00047 
00048 typedef Map<String, String> HTTPHeaderMap;
00049 namespace HTTPUtils
00050 {
00051    extern OW_HTTP_API const char* const Header_BypassLocker; 
00052    extern OW_HTTP_API const char* const HeaderValue_true; 
00053    extern OW_HTTP_API const char* const HeaderValue_false; 
00063    OW_HTTP_API bool parseHeader(HTTPHeaderMap& map, Array<String>& array,
00064                            std::istream& istr);
00072    OW_HTTP_API bool parseHeader(HTTPHeaderMap& map, std::istream& istr);
00077    OW_HTTP_API String date( void );
00083    OW_HTTP_API String status2String(int code);
00088    OW_HTTP_API String getCounterStr();
00093    OW_HTTP_API String base64Decode(const String& arg);
00099    OW_HTTP_API Array<char> base64Decode(const char* src);
00104    OW_HTTP_API String base64Encode(const String& arg);
00110    OW_HTTP_API String base64Encode(const char* src);
00117    OW_HTTP_API String base64Encode(const UInt8* src, size_t len);
00118 #ifndef OW_DISABLE_DIGEST
00119    /* calculate H(A1) as per HTTP Digest spec */
00120    OW_HTTP_API void DigestCalcHA1(
00121                const String &sAlg,
00122                const String &sUserName,
00123                const String &sRealm,
00124                const String &sPassword,
00125                const String &sNonce,
00126                const String &sCNonce,
00127                String &sSessionKey
00128                  );
00129    /* calculate request-digest/response-digest as per HTTP Digest spec */
00130    OW_HTTP_API void DigestCalcResponse(
00131                const String &sHA1,        /* H(A1) */
00132                const String &sNonce,      /* nonce from server */
00133                const String &sNonceCount, /* 8 hex digits */
00134                const String &sCNonce,     /* client nonce */
00135                const String &sQop,        /* qop-value: "", "auth", "auth-int" */
00136                const String &sMethod,     /* method from the request */
00137                const String &sDigestUri,  /* requested URL */
00138                const String &sHEntity,    /* H(entity body) if qop="auth-int" */
00139                String &Response
00140                      );
00141 #endif
00142 
00148    OW_HTTP_API bool headerHasKey(const HTTPHeaderMap& headers,
00149       const String& key);
00156    OW_HTTP_API String getHeaderValue(const HTTPHeaderMap& headers,
00157       const String& key);
00164    OW_HTTP_API void addHeader(Array<String>& headers,
00165       const String& key, const String& value);
00174    OW_HTTP_API void eatEntity(std::istream& istr);
00182    OW_HTTP_API void decodeBasicCreds(const String& info, String& name,
00183       String& password);
00184    
00185    OW_HTTP_API bool buildMap(HTTPHeaderMap& map, std::istream& istr);
00192    OW_HTTP_API String escapeCharForURL(char c);
00193 
00194    OW_DECLARE_APIEXCEPTION(UnescapeCharForURL, OW_HTTP_API);
00204    OW_HTTP_API char unescapeCharForURL(const char* str);
00211    OW_HTTP_API String escapeForURL(const String& input);
00218    OW_HTTP_API String unescapeForURL(const String& input);
00219 };
00220 
00221 } // end namespace OW_NAMESPACE
00222 
00223 namespace OW_HTTPUtils = OW_NAMESPACE::HTTPUtils;
00224 
00225 #endif   // OW_HTTPUTILS_HPP_

Generated on Thu Feb 9 08:48:00 2006 for openwbem by  doxygen 1.4.6