Merged manually from caxapniy/s3fs-fuse/tree/1.77v4merge for signature v4 - #102
This commit is contained in:
@ -125,6 +125,12 @@ string urlEncode(const string &s)
|
||||
for (unsigned i = 0; i < s.length(); ++i) {
|
||||
if (s[i] == '/') { // Note- special case for fuse paths...
|
||||
result += s[i];
|
||||
#ifndef SIGV3
|
||||
}else if (s[i] == '=') { // Note- special case for s3...
|
||||
result += s[i];
|
||||
}else if (s[i] == '&') { // Note- special case for s3...
|
||||
result += s[i];
|
||||
#endif
|
||||
} else if (isalnum(s[i])) {
|
||||
result += s[i];
|
||||
} else if (s[i] == '.' || s[i] == '-' || s[i] == '*' || s[i] == '_') {
|
||||
@ -143,6 +149,39 @@ string urlEncode(const string &s)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef SIGV3
|
||||
/**
|
||||
* urlEncode a fuse path,
|
||||
* taking into special consideration "/",
|
||||
* otherwise regular urlEncode.
|
||||
*/
|
||||
string urlEncode2(const string &s)
|
||||
{
|
||||
string result;
|
||||
for (unsigned i = 0; i < s.length(); ++i) {
|
||||
if (s[i] == '=') { // Note- special case for fuse paths...
|
||||
result += s[i];
|
||||
}else if (s[i] == '&') { // Note- special case for s3...
|
||||
result += s[i];
|
||||
} else if (isalnum(s[i])) {
|
||||
result += s[i];
|
||||
} else if (s[i] == '.' || s[i] == '-' || s[i] == '*' || s[i] == '_') {
|
||||
result += s[i];
|
||||
} else if (s[i] == ' ') {
|
||||
result += '%';
|
||||
result += '2';
|
||||
result += '0';
|
||||
} else {
|
||||
result += "%";
|
||||
result += hexAlphabet[static_cast<unsigned char>(s[i]) / 16];
|
||||
result += hexAlphabet[static_cast<unsigned char>(s[i]) % 16];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// ex. target="http://......?keyword=value&..."
|
||||
//
|
||||
@ -181,6 +220,25 @@ string get_date()
|
||||
return buf;
|
||||
}
|
||||
|
||||
#ifndef SIGV3
|
||||
string get_date2()
|
||||
{
|
||||
char buf[100];
|
||||
time_t t = time(NULL);
|
||||
strftime(buf, sizeof(buf), "%Y%m%d", gmtime(&t));
|
||||
return buf;
|
||||
}
|
||||
|
||||
string get_date3()
|
||||
{
|
||||
char buf[100];
|
||||
time_t t = time(NULL);
|
||||
strftime(buf, sizeof(buf), "%Y%m%dT%H%M%SZ", gmtime(&t));
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
||||
Reference in New Issue
Block a user