File indexing completed on 2025-01-18 10:12:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_TS3HTTPRequest
0014 #define ROOT_TS3HTTPRequest
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #include "TObject.h"
0040
0041 #include "TString.h"
0042
0043
0044
0045 class TS3HTTPRequest : public TObject {
0046
0047 public:
0048
0049 enum EHTTPVerb { kGET, kPOST, kPUT, kDELETE, kHEAD, kCOPY };
0050 enum EAuthType { kNoAuth, kAmazon, kGoogle };
0051
0052 private:
0053 EHTTPVerb fVerb;
0054 EAuthType fAuthType;
0055 TString fHost;
0056 TString fBucket;
0057 TString fObjectKey;
0058 TString fTimeStamp;
0059 TString fAccessKey;
0060 TString fSecretKey;
0061 TString fSessionToken;
0062
0063
0064 protected:
0065 TString HTTPVerbToTString(EHTTPVerb httpVerb) const;
0066 TString MakeRequestLine(TS3HTTPRequest::EHTTPVerb httpVerb) const;
0067 TString MakeAuthHeader(TS3HTTPRequest::EHTTPVerb httpVerb) const;
0068 TString ComputeSignature(TS3HTTPRequest::EHTTPVerb httpVerb) const;
0069 TString MakeAuthPrefix() const;
0070 TString MakeHostHeader() const;
0071 TString MakeDateHeader() const;
0072 TString MakeTokenHeader() const;
0073 TS3HTTPRequest& SetTimeStamp();
0074
0075 public:
0076
0077 TS3HTTPRequest();
0078 TS3HTTPRequest(EHTTPVerb httpVerb, const TString& host,
0079 const TString& bucket, const TString& objectKey,
0080 EAuthType authType, const TString& accessKey,
0081 const TString& secretKey);
0082 TS3HTTPRequest(const TS3HTTPRequest& m);
0083 virtual ~TS3HTTPRequest() {}
0084
0085 EHTTPVerb GetHTTPVerb() const { return fVerb; }
0086 const TString& GetHost() const { return fHost; }
0087 const TString& GetBucket() const { return fBucket; }
0088 const TString& GetObjectKey() const { return fObjectKey; }
0089 const TString& GetTimeStamp() const { return fTimeStamp; }
0090 const TString& GetAccessKey() const { return fAccessKey; }
0091 const TString& GetSecretKey() const { return fSecretKey; }
0092 TString GetAuthType() const { return fAuthType; }
0093 TString GetRequest(TS3HTTPRequest::EHTTPVerb httpVerb, Bool_t appendCRLF=kTRUE);
0094
0095 TS3HTTPRequest& SetHost(const TString& host);
0096 TS3HTTPRequest& SetBucket(const TString& bucket);
0097 TS3HTTPRequest& SetObjectKey(const TString& objectKey);
0098 TS3HTTPRequest& SetAccessKey(const TString& accessKey);
0099 TS3HTTPRequest& SetSecretKey(const TString& secretKey);
0100 TS3HTTPRequest& SetAuthKeys(const TString& accessKey, const TString& secretKey);
0101 TS3HTTPRequest& SetAuthType(TS3HTTPRequest::EAuthType authType);
0102 TS3HTTPRequest& SetSessionToken(const TString& token);
0103
0104 ClassDefOverride(TS3HTTPRequest, 0)
0105 };
0106
0107
0108
0109
0110
0111
0112
0113
0114 inline TS3HTTPRequest& TS3HTTPRequest::SetHost(const TString& host)
0115 {
0116 fHost = host;
0117 return *this;
0118 }
0119
0120 inline TS3HTTPRequest& TS3HTTPRequest::SetBucket(const TString& bucket)
0121 {
0122 fBucket = bucket;
0123 return *this;
0124 }
0125
0126 inline TS3HTTPRequest& TS3HTTPRequest::SetObjectKey(const TString& objectKey)
0127 {
0128 fObjectKey = objectKey;
0129 return *this;
0130 }
0131
0132 inline TS3HTTPRequest& TS3HTTPRequest::SetAuthKeys(const TString& accessKey, const TString& secretKey)
0133 {
0134 fAccessKey = accessKey;
0135 fSecretKey = secretKey;
0136 return *this;
0137 }
0138
0139 inline TS3HTTPRequest& TS3HTTPRequest::SetAuthType(TS3HTTPRequest::EAuthType authType)
0140 {
0141 fAuthType = authType;
0142 return *this;
0143 }
0144
0145 inline TS3HTTPRequest& TS3HTTPRequest::SetAccessKey(const TString& accessKey)
0146 {
0147 fAccessKey = accessKey;
0148 return *this;
0149 }
0150
0151 inline TS3HTTPRequest& TS3HTTPRequest::SetSecretKey(const TString& secretKey)
0152 {
0153 fSecretKey = secretKey;
0154 return *this;
0155 }
0156
0157 inline TS3HTTPRequest& TS3HTTPRequest::SetSessionToken(const TString& token)
0158 {
0159 fSessionToken = token;
0160 return *this;
0161 }
0162
0163 #endif