Utility functions for XrdHTTP. More...
#include "XrdHttpUtils.hh"#include <cstring>#include <openssl/hmac.h>#include <openssl/bio.h>#include <openssl/buffer.h>#include <openssl/err.h>#include <openssl/ssl.h>#include "sys/param.h"#include <pthread.h>#include <memory>#include <vector>#include <algorithm>#include "XrdSec/XrdSecEntity.hh"#include "XrdOuc/XrdOucString.hh"Go to the source code of this file.
Functions | |
| void | base64DecodeHex (const std::string &base64, std::string &hexOutput) |
| void | base64ToBytes (const std::string &base64digest, std::vector< uint8_t > &outputBytes) |
| void | bytesToHex (const std::vector< uint8_t > &bytes, std::string &output) |
| void | calcHashes (char *hash, const char *fn, kXR_int16 request, XrdSecEntity *secent, time_t tim, const char *key) |
| static int | char_to_int (int ch) |
| int | compareHash (const char *h1, const char *h2) |
| char * | escapeXML (const char *str) |
| bool | Fromhexdigest (const std::string &hex, std::vector< uint8_t > &outputBytes) |
| std::string | httpBuildRedirectLocation (bool destHttps, int port, const char *hname, const char *encodedResource) |
| std::string | httpCollapseSlashes (std::string path) |
| std::string | httpPathFromAbsoluteUrl (const char *hname) |
| Path starting at the first / after the authority. An absent path is /. | |
| std::string | httpStatusToString (int status) |
| std::string | itos (long i) |
| int | mapErrNoToHttp (int errNo) |
| int | mapXrdErrToHttp (XErrorCode xrdError) |
| char * | mystrchrnul (const char *s, int c) |
| char * | quote (const char *str) |
| void | Tobase64 (const std::vector< uint8_t > &input, std::string &base64Output) |
| void | Tobase64 (const unsigned char *input, int length, char *out) |
| char * | unquote (char *str) |
| void base64DecodeHex | ( | const std::string & | base64, |
| std::string & | hexOutput ) |
Definition at line 155 of file XrdHttpUtils.cc.
References base64DecodeHex(), base64ToBytes(), and bytesToHex().
Referenced by base64DecodeHex(), and XrdHttpHeaderUtils::parseReprDigest().
| void base64ToBytes | ( | const std::string & | base64digest, |
| std::vector< uint8_t > & | outputBytes ) |
Definition at line 118 of file XrdHttpUtils.cc.
References base64ToBytes().
Referenced by base64DecodeHex(), and base64ToBytes().
| void bytesToHex | ( | const std::vector< uint8_t > & | bytes, |
| std::string & | output ) |
Definition at line 145 of file XrdHttpUtils.cc.
References bytesToHex().
Referenced by base64DecodeHex(), and bytesToHex().
| void calcHashes | ( | char * | hash, |
| const char * | fn, | ||
| kXR_int16 | request, | ||
| XrdSecEntity * | secent, | ||
| time_t | tim, | ||
| const char * | key ) |
Definition at line 231 of file XrdHttpUtils.cc.
References calcHashes(), XrdSecEntity::host, XrdSecEntity::moninfo, XrdSecEntity::name, Tobase64(), and XrdSecEntity::vorg.
Referenced by calcHashes(), XrdHttpProtocol::Process(), and XrdHttpReq::Redir().
|
static |
Definition at line 163 of file XrdHttpUtils.cc.
References char_to_int().
Referenced by char_to_int(), and Fromhexdigest().
| int compareHash | ( | const char * | h1, |
| const char * | h2 ) |
Definition at line 376 of file XrdHttpUtils.cc.
References compareHash().
Referenced by compareHash(), and XrdHttpProtocol::Process().
| char * escapeXML | ( | const char * | str | ) |
Definition at line 482 of file XrdHttpUtils.cc.
References escapeXML().
Referenced by XrdHttpReq::Error(), and escapeXML().
| bool Fromhexdigest | ( | const std::string & | hex, |
| std::vector< uint8_t > & | outputBytes ) |
Definition at line 177 of file XrdHttpUtils.cc.
References char_to_int(), and Fromhexdigest().
Referenced by Fromhexdigest().
| std::string httpBuildRedirectLocation | ( | bool | destHttps, |
| int | port, | ||
| const char * | hname, | ||
| const char * | encodedResource ) |
Build the Location: header for an HTTP redirect (without auth opaque). When port < 0, hname is a full URL (XRootD URL-form redirect): emit as-is and ignore encodedResource. Otherwise: Location: http(s)://hname[:port]<encodedResource>.
Definition at line 707 of file XrdHttpUtils.cc.
References httpBuildRedirectLocation().
Referenced by httpBuildRedirectLocation(), and XrdHttpReq::Redir().
| std::string httpCollapseSlashes | ( | std::string | path | ) |
Collapse duplicate slashes in a path. Applied to an already-decoded path, decode_str() then this yields the canonical request path. Shared by XrdHttpReq::parseResource() and the redirect token path so that the two ends of a redirect always hash an identical string.
Definition at line 700 of file XrdHttpUtils.cc.
References httpCollapseSlashes().
Referenced by httpCollapseSlashes(), and XrdHttpReq::Redir().
| std::string httpPathFromAbsoluteUrl | ( | const char * | hname | ) |
Path starting at the first / after the authority. An absent path is /.
Definition at line 689 of file XrdHttpUtils.cc.
References httpPathFromAbsoluteUrl().
Referenced by httpPathFromAbsoluteUrl(), and XrdHttpReq::Redir().
| std::string httpStatusToString | ( | int | status | ) |
Definition at line 603 of file XrdHttpUtils.cc.
References httpStatusToString().
Referenced by httpStatusToString().
| std::string itos | ( | long | i | ) |
Definition at line 195 of file XrdHttpUtils.cc.
References itos().
Referenced by itos().
| int mapErrNoToHttp | ( | int | errNo | ) |
Definition at line 530 of file XrdHttpUtils.cc.
References EAUTH, HTTP_BAD_GATEWAY, HTTP_BAD_REQUEST, HTTP_CONFLICT, HTTP_FORBIDDEN, HTTP_GATEWAY_TIMEOUT, HTTP_INSUFFICIENT_STORAGE, HTTP_INTERNAL_SERVER_ERROR, HTTP_LOOP_DETECTED, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_PAYLOAD_TOO_LARGE, HTTP_SERVICE_UNAVAILABLE, HTTP_UNAUTHORIZED, HTTP_UNPROCESSABLE_ENTITY, HTTP_URI_TOO_LONG, and mapErrNoToHttp().
Referenced by mapErrNoToHttp(), and mapXrdErrToHttp().
| int mapXrdErrToHttp | ( | XErrorCode | xrdError | ) |
Definition at line 523 of file XrdHttpUtils.cc.
References mapErrNoToHttp(), mapXrdErrToHttp(), and XProtocol::toErrno().
Referenced by mapXrdErrToHttp().
| char * mystrchrnul | ( | const char * | s, |
| int | c ) |
Definition at line 205 of file XrdHttpUtils.cc.
References mystrchrnul().
Referenced by mystrchrnul().
| char * quote | ( | const char * | str | ) |
Definition at line 423 of file XrdHttpUtils.cc.
References quote().
Referenced by encode_raw(), and quote().
| void Tobase64 | ( | const std::vector< uint8_t > & | input, |
| std::string & | base64Output ) |
Definition at line 90 of file XrdHttpUtils.cc.
References Tobase64().
| void Tobase64 | ( | const unsigned char * | input, |
| int | length, | ||
| char * | out ) |
Definition at line 60 of file XrdHttpUtils.cc.
References Tobase64().
Referenced by calcHashes(), Tobase64(), and Tobase64().
| char * unquote | ( | char * | str | ) |
Definition at line 391 of file XrdHttpUtils.cc.
References unquote().
Referenced by decode_raw(), unquote(), and unquote().