mirror of
https://github.com/minio/minio-cpp.git
synced 2025-07-03 14:22:32 +03:00
Include headers explicitly and add constructors to comply C++20 (#116)
* Added constructors to become C++20 * fixed: implementation details leak in headers
This commit is contained in:
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Declare files that will always have LF line endings on checkout.
|
||||||
|
*.sh test eol=lf
|
@ -13,7 +13,16 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
#include "args.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "request.h"
|
||||||
|
#include "response.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Create S3 base URL.
|
// Create S3 base URL.
|
||||||
|
@ -13,7 +13,17 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
#include "args.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "request.h"
|
||||||
|
#include "response.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
// Create S3 base URL.
|
// Create S3 base URL.
|
||||||
|
@ -16,10 +16,17 @@
|
|||||||
#ifndef _MINIO_S3_ARGS_H
|
#ifndef _MINIO_S3_ARGS_H
|
||||||
#define _MINIO_S3_ARGS_H
|
#define _MINIO_S3_ARGS_H
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "signer.h"
|
|
||||||
#include "sse.h"
|
#include "sse.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace s3 {
|
namespace s3 {
|
||||||
|
@ -16,11 +16,18 @@
|
|||||||
#ifndef _MINIO_S3_BASE_CLIENT_H
|
#ifndef _MINIO_S3_BASE_CLIENT_H
|
||||||
#define _MINIO_S3_BASE_CLIENT_H
|
#define _MINIO_S3_BASE_CLIENT_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
#include "request.h"
|
#include "request.h"
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
#include "select.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace s3 {
|
namespace s3 {
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
#ifndef _MINIO_S3_CLIENT_H
|
#ifndef _MINIO_S3_CLIENT_H
|
||||||
#define _MINIO_S3_CLIENT_H
|
#define _MINIO_S3_CLIENT_H
|
||||||
|
|
||||||
#include <fstream>
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
#include "baseclient.h"
|
#include "baseclient.h"
|
||||||
#include "config.h"
|
#include "error.h"
|
||||||
|
#include "providers.h"
|
||||||
#include "request.h"
|
#include "request.h"
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
#ifndef _MINIO_CREDS_CREDENTIALS_H
|
#ifndef _MINIO_CREDS_CREDENTIALS_H
|
||||||
#define _MINIO_CREDS_CREDENTIALS_H
|
#define _MINIO_CREDS_CREDENTIALS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
@ -34,6 +38,30 @@ struct Credentials {
|
|||||||
utils::UtcTime expiration = {};
|
utils::UtcTime expiration = {};
|
||||||
|
|
||||||
Credentials() = default;
|
Credentials() = default;
|
||||||
|
explicit Credentials(error::Error err) : err(std::move(err)) {}
|
||||||
|
|
||||||
|
explicit Credentials(error::Error err, std::string access_key,
|
||||||
|
std::string secret_key)
|
||||||
|
: err(std::move(err)),
|
||||||
|
access_key(std::move(access_key)),
|
||||||
|
secret_key(std::move(secret_key)) {}
|
||||||
|
|
||||||
|
explicit Credentials(error::Error err, std::string access_key,
|
||||||
|
std::string secret_key, std::string session_token)
|
||||||
|
: err(std::move(err)),
|
||||||
|
access_key(std::move(access_key)),
|
||||||
|
secret_key(std::move(secret_key)),
|
||||||
|
session_token(std::move(session_token)) {}
|
||||||
|
|
||||||
|
explicit Credentials(error::Error err, std::string access_key,
|
||||||
|
std::string secret_key, std::string session_token,
|
||||||
|
utils::UtcTime expiration)
|
||||||
|
: err(std::move(err)),
|
||||||
|
access_key(std::move(access_key)),
|
||||||
|
secret_key(std::move(secret_key)),
|
||||||
|
session_token(std::move(session_token)),
|
||||||
|
expiration(std::move(expiration)) {}
|
||||||
|
|
||||||
~Credentials() = default;
|
~Credentials() = default;
|
||||||
|
|
||||||
bool IsExpired() const { return expired(expiration); }
|
bool IsExpired() const { return expired(expiration); }
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace error {
|
namespace error {
|
||||||
@ -32,9 +33,9 @@ class Error {
|
|||||||
Error(const Error&) = default;
|
Error(const Error&) = default;
|
||||||
Error& operator=(const Error&) = default;
|
Error& operator=(const Error&) = default;
|
||||||
|
|
||||||
Error(Error&& v) : msg_(std::move(v.msg_)) {}
|
Error(Error&& v) noexcept : msg_(std::move(v.msg_)) {}
|
||||||
|
|
||||||
Error& operator=(Error&& v) {
|
Error& operator=(Error&& v) noexcept {
|
||||||
if (this != &v) {
|
if (this != &v) {
|
||||||
msg_ = std::move(v.msg_);
|
msg_ = std::move(v.msg_);
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,15 @@
|
|||||||
#ifndef _MINIO_HTTP_H
|
#ifndef _MINIO_HTTP_H
|
||||||
#define _MINIO_HTTP_H
|
#define _MINIO_HTTP_H
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#else
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <curlpp/Easy.hpp>
|
#include <curlpp/Easy.hpp>
|
||||||
#include <curlpp/Multi.hpp>
|
#include <curlpp/Multi.hpp>
|
||||||
#include <curlpp/Options.hpp>
|
#include <exception>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
@ -65,6 +64,13 @@ struct Url {
|
|||||||
std::string query_string;
|
std::string query_string;
|
||||||
|
|
||||||
Url() = default;
|
Url() = default;
|
||||||
|
explicit Url(bool https, std::string host, unsigned int port,
|
||||||
|
std::string path, std::string query_string)
|
||||||
|
: https(https),
|
||||||
|
host(std::move(host)),
|
||||||
|
port(port),
|
||||||
|
path(std::move(path)),
|
||||||
|
query_string(std::move(query_string)) {}
|
||||||
~Url() = default;
|
~Url() = default;
|
||||||
|
|
||||||
explicit operator bool() const { return !host.empty(); }
|
explicit operator bool() const { return !host.empty(); }
|
||||||
@ -91,6 +97,16 @@ struct DataFunctionArgs {
|
|||||||
void* userdata = nullptr;
|
void* userdata = nullptr;
|
||||||
|
|
||||||
DataFunctionArgs() = default;
|
DataFunctionArgs() = default;
|
||||||
|
explicit DataFunctionArgs(curlpp::Easy* handle, Response* response,
|
||||||
|
void* userdata)
|
||||||
|
: handle(handle), response(response), userdata(userdata) {}
|
||||||
|
explicit DataFunctionArgs(curlpp::Easy* handle, Response* response,
|
||||||
|
std::string datachunk, void* userdata)
|
||||||
|
: handle(handle),
|
||||||
|
response(response),
|
||||||
|
datachunk(std::move(datachunk)),
|
||||||
|
userdata(userdata) {}
|
||||||
|
|
||||||
~DataFunctionArgs() = default;
|
~DataFunctionArgs() = default;
|
||||||
}; // struct DataFunctionArgs
|
}; // struct DataFunctionArgs
|
||||||
|
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
#ifndef _MINIO_CREDS_PROVIDERS_H
|
#ifndef _MINIO_CREDS_PROVIDERS_H
|
||||||
#define _MINIO_CREDS_PROVIDERS_H
|
#define _MINIO_CREDS_PROVIDERS_H
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <functional>
|
||||||
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "credentials.h"
|
#include "credentials.h"
|
||||||
|
#include "error.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
#define DEFAULT_DURATION_SECONDS (60 * 60 * 24) // 1 day.
|
#define DEFAULT_DURATION_SECONDS (60 * 60 * 24) // 1 day.
|
||||||
@ -34,6 +36,8 @@ struct Jwt {
|
|||||||
unsigned int expiry = 0;
|
unsigned int expiry = 0;
|
||||||
|
|
||||||
Jwt() = default;
|
Jwt() = default;
|
||||||
|
explicit Jwt(std::string token, unsigned int expiry)
|
||||||
|
: token(std::move(token)), expiry(expiry) {}
|
||||||
~Jwt() = default;
|
~Jwt() = default;
|
||||||
|
|
||||||
explicit operator bool() const { return !token.empty(); }
|
explicit operator bool() const { return !token.empty(); }
|
||||||
|
@ -16,9 +16,13 @@
|
|||||||
#ifndef _MINIO_REQUEST_H
|
#ifndef _MINIO_REQUEST_H
|
||||||
#define _MINIO_REQUEST_H
|
#define _MINIO_REQUEST_H
|
||||||
|
|
||||||
#include "credentials.h"
|
#include <regex>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
#include "providers.h"
|
#include "providers.h"
|
||||||
#include "signer.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace s3 {
|
namespace s3 {
|
||||||
|
@ -16,9 +16,14 @@
|
|||||||
#ifndef _MINIO_S3_RESPONSE_H
|
#ifndef _MINIO_S3_RESPONSE_H
|
||||||
#define _MINIO_S3_RESPONSE_H
|
#define _MINIO_S3_RESPONSE_H
|
||||||
|
|
||||||
#include <pugixml.hpp>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace s3 {
|
namespace s3 {
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
#ifndef _MINIO_S3_SELECT_H
|
#ifndef _MINIO_S3_SELECT_H
|
||||||
#define _MINIO_S3_SELECT_H
|
#define _MINIO_S3_SELECT_H
|
||||||
|
|
||||||
#include <pugixml.hpp>
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
#ifndef _MINIO_SIGNER_H
|
#ifndef _MINIO_SIGNER_H
|
||||||
#define _MINIO_SIGNER_H
|
#define _MINIO_SIGNER_H
|
||||||
|
|
||||||
#include <openssl/hmac.h>
|
#include <string>
|
||||||
|
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace signer {
|
namespace signer {
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#ifndef _MINIO_S3_SSE_H
|
#ifndef _MINIO_S3_SSE_H
|
||||||
#define _MINIO_S3_SSE_H
|
#define _MINIO_S3_SSE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
|
@ -16,10 +16,17 @@
|
|||||||
#ifndef _MINIO_S3_TYPES_H
|
#ifndef _MINIO_S3_TYPES_H
|
||||||
#define _MINIO_S3_TYPES_H
|
#define _MINIO_S3_TYPES_H
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <nlohmann/json_fwd.hpp>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
@ -310,6 +317,8 @@ struct Bucket {
|
|||||||
utils::UtcTime creation_date;
|
utils::UtcTime creation_date;
|
||||||
|
|
||||||
Bucket() = default;
|
Bucket() = default;
|
||||||
|
explicit Bucket(std::string name, utils::UtcTime creation_date)
|
||||||
|
: name(std::move(name)), creation_date(std::move(creation_date)) {}
|
||||||
~Bucket() = default;
|
~Bucket() = default;
|
||||||
}; // struct Bucket
|
}; // struct Bucket
|
||||||
|
|
||||||
@ -320,6 +329,8 @@ struct Part {
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
Part() = default;
|
Part() = default;
|
||||||
|
explicit Part(unsigned int number, std::string etag)
|
||||||
|
: number(number), etag(std::move(etag)) {}
|
||||||
~Part() = default;
|
~Part() = default;
|
||||||
}; // struct Part
|
}; // struct Part
|
||||||
|
|
||||||
|
@ -20,34 +20,23 @@
|
|||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <openssl/buffer.h>
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <zlib.h>
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <chrono>
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstring>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <curlpp/cURLpp.hpp>
|
#include <ios>
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <ostream>
|
|
||||||
#include <regex>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
namespace minio {
|
namespace minio {
|
||||||
namespace utils {
|
namespace utils {
|
||||||
inline constexpr unsigned int kMaxMultipartCount = 10000; // 10000 parts
|
inline constexpr unsigned int kMaxMultipartCount = 10000; // 10000 parts
|
||||||
inline constexpr unsigned long long kMaxObjectSize = 5497558138880ULL; // 5TiB
|
inline constexpr uint64_t kMaxObjectSize = 5'497'558'138'880; // 5TiB
|
||||||
inline constexpr unsigned long long kMaxPartSize = 5368709120UL; // 5GiB
|
inline constexpr uint64_t kMaxPartSize = 5'368'709'120; // 5GiB
|
||||||
inline constexpr unsigned int kMinPartSize = 5 * 1024 * 1024; // 5MiB
|
inline constexpr unsigned int kMinPartSize = 5 * 1024 * 1024; // 5MiB
|
||||||
|
|
||||||
// GetEnv copies the environment variable name into var
|
// GetEnv copies the environment variable name into var
|
||||||
bool GetEnv(std::string& var, const char* name);
|
bool GetEnv(std::string& var, const char* name);
|
||||||
@ -72,7 +61,7 @@ inline const char* BoolToString(bool b) { return b ? "true" : "false"; }
|
|||||||
// Trim trims leading and trailing character of a string.
|
// Trim trims leading and trailing character of a string.
|
||||||
std::string Trim(std::string_view str, char ch = ' ');
|
std::string Trim(std::string_view str, char ch = ' ');
|
||||||
|
|
||||||
// CheckNonemptystring checks whether string is not empty after trimming
|
// CheckNonEmptyString checks whether string is not empty after trimming
|
||||||
// whitespaces.
|
// whitespaces.
|
||||||
bool CheckNonEmptyString(std::string_view str);
|
bool CheckNonEmptyString(std::string_view str);
|
||||||
|
|
||||||
|
19
src/args.cc
19
src/args.cc
@ -15,8 +15,21 @@
|
|||||||
|
|
||||||
#include "args.h"
|
#include "args.h"
|
||||||
|
|
||||||
|
#include <curlpp/cURLpp.hpp>
|
||||||
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <ostream>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "signer.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
minio::error::Error minio::s3::BucketArgs::Validate() const {
|
minio::error::Error minio::s3::BucketArgs::Validate() const {
|
||||||
return utils::CheckBucketName(bucket);
|
return utils::CheckBucketName(bucket);
|
||||||
@ -346,7 +359,7 @@ minio::error::Error minio::s3::ComposeSource::BuildHeaders(
|
|||||||
size_t minio::s3::ComposeSource::ObjectSize() const {
|
size_t minio::s3::ComposeSource::ObjectSize() const {
|
||||||
if (object_size_ == -1) {
|
if (object_size_ == -1) {
|
||||||
std::cerr << "ABORT: ComposeSource::BuildHeaders() must be called prior to "
|
std::cerr << "ABORT: ComposeSource::BuildHeaders() must be called prior to "
|
||||||
"this method invocation. This shoud not happen."
|
"this method invocation. This should not happen."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
@ -357,7 +370,7 @@ size_t minio::s3::ComposeSource::ObjectSize() const {
|
|||||||
minio::utils::Multimap minio::s3::ComposeSource::Headers() const {
|
minio::utils::Multimap minio::s3::ComposeSource::Headers() const {
|
||||||
if (!headers_) {
|
if (!headers_) {
|
||||||
std::cerr << "ABORT: ComposeSource::BuildHeaders() must be called prior to "
|
std::cerr << "ABORT: ComposeSource::BuildHeaders() must be called prior to "
|
||||||
"this method invocation. This shoud not happen."
|
"this method invocation. This should not happen."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::terminate();
|
std::terminate();
|
||||||
}
|
}
|
||||||
@ -441,7 +454,7 @@ minio::error::Error minio::s3::ListenBucketNotificationArgs::Validate() const {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
if (func == nullptr) {
|
if (func == nullptr) {
|
||||||
error::Error("notification records function must be set");
|
return error::Error("notification records function must be set");
|
||||||
}
|
}
|
||||||
return error::SUCCESS;
|
return error::SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,32 @@
|
|||||||
|
|
||||||
#include "baseclient.h"
|
#include "baseclient.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <exception>
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <ostream>
|
||||||
|
#include <pugixml.hpp>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "args.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "credentials.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "request.h"
|
||||||
|
#include "response.h"
|
||||||
|
#include "select.h"
|
||||||
|
#include "signer.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
minio::utils::Multimap minio::s3::GetCommonListObjectsQueryParams(
|
minio::utils::Multimap minio::s3::GetCommonListObjectsQueryParams(
|
||||||
const std::string& delimiter, const std::string& encoding_type,
|
const std::string& delimiter, const std::string& encoding_type,
|
||||||
unsigned int max_keys, const std::string& prefix) {
|
unsigned int max_keys, const std::string& prefix) {
|
||||||
@ -955,7 +981,7 @@ minio::s3::BaseClient::GetPresignedPostFormData(PostPolicy policy) {
|
|||||||
|
|
||||||
if (provider_ == nullptr) {
|
if (provider_ == nullptr) {
|
||||||
return error::Error(
|
return error::Error(
|
||||||
"Anonymous access does not require presigned post form-data");
|
"Anonymous access does not require pre-signed post form-data");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string region;
|
std::string region;
|
||||||
|
@ -15,6 +15,26 @@
|
|||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
|
#include <curlpp/cURLpp.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <system_error>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "args.h"
|
||||||
|
#include "baseclient.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "request.h"
|
||||||
|
#include "response.h"
|
||||||
|
#include "sse.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
minio::s3::ListObjectsResult::ListObjectsResult(error::Error err)
|
minio::s3::ListObjectsResult::ListObjectsResult(error::Error err)
|
||||||
: failed_(true) {
|
: failed_(true) {
|
||||||
this->resp_.contents.push_back(Item(std::move(err)));
|
this->resp_.contents.push_back(Item(std::move(err)));
|
||||||
@ -284,7 +304,7 @@ minio::s3::ComposeObjectResponse minio::s3::Client::ComposeObject(
|
|||||||
upc_args.part_number = part_number;
|
upc_args.part_number = part_number;
|
||||||
UploadPartCopyResponse resp = UploadPartCopy(upc_args);
|
UploadPartCopyResponse resp = UploadPartCopy(upc_args);
|
||||||
if (!resp) return resp;
|
if (!resp) return resp;
|
||||||
parts.push_back(Part{part_number, resp.etag});
|
parts.push_back(Part(part_number, std::move(resp.etag)));
|
||||||
} else {
|
} else {
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
part_number++;
|
part_number++;
|
||||||
@ -306,10 +326,11 @@ minio::s3::ComposeObjectResponse minio::s3::Client::ComposeObject(
|
|||||||
upc_args.headers = headerscopy;
|
upc_args.headers = headerscopy;
|
||||||
upc_args.upload_id = upload_id;
|
upc_args.upload_id = upload_id;
|
||||||
upc_args.part_number = part_number;
|
upc_args.part_number = part_number;
|
||||||
UploadPartCopyResponse resp = UploadPartCopy(upc_args);
|
{
|
||||||
if (!resp) return resp;
|
UploadPartCopyResponse resp = UploadPartCopy(upc_args);
|
||||||
parts.push_back(Part{part_number, resp.etag});
|
if (!resp) return resp;
|
||||||
|
parts.push_back(Part(part_number, std::move(resp.etag)));
|
||||||
|
}
|
||||||
offset = start_bytes;
|
offset = start_bytes;
|
||||||
size -= (end_bytes - start_bytes);
|
size -= (end_bytes - start_bytes);
|
||||||
}
|
}
|
||||||
@ -475,7 +496,7 @@ minio::s3::PutObjectResponse minio::s3::Client::PutObject(
|
|||||||
actual_args.userdata = args.progress_userdata;
|
actual_args.userdata = args.progress_userdata;
|
||||||
args.progressfunc(actual_args);
|
args.progressfunc(actual_args);
|
||||||
}
|
}
|
||||||
parts.push_back(Part{part_number, resp.etag});
|
parts.push_back(Part(part_number, std::move(resp.etag)));
|
||||||
} else {
|
} else {
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
#include "credentials.h"
|
#include "credentials.h"
|
||||||
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
bool minio::creds::expired(const utils::UtcTime& expiration) {
|
bool minio::creds::expired(const utils::UtcTime& expiration) {
|
||||||
if (!expiration) return false;
|
if (!expiration) return false;
|
||||||
@ -44,6 +49,7 @@ minio::creds::Credentials minio::creds::Credentials::ParseXML(
|
|||||||
text = credentials.node().select_node("Expiration/text()");
|
text = credentials.node().select_node("Expiration/text()");
|
||||||
auto expiration = utils::UtcTime::FromISO8601UTC(text.node().value());
|
auto expiration = utils::UtcTime::FromISO8601UTC(text.node().value());
|
||||||
|
|
||||||
return Credentials{error::SUCCESS, access_key, secret_key, session_token,
|
return Credentials(error::SUCCESS, std::move(access_key),
|
||||||
expiration};
|
std::move(secret_key), std::move(session_token),
|
||||||
|
expiration);
|
||||||
}
|
}
|
||||||
|
44
src/http.cc
44
src/http.cc
@ -13,9 +13,37 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "http.h"
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
#include <curlpp/Easy.hpp>
|
||||||
|
#include <curlpp/Exception.hpp>
|
||||||
#include <curlpp/Infos.hpp>
|
#include <curlpp/Infos.hpp>
|
||||||
|
#include <curlpp/Multi.hpp>
|
||||||
|
#include <curlpp/Options.hpp>
|
||||||
|
#include <curlpp/cURLpp.hpp>
|
||||||
|
#include <exception>
|
||||||
|
#include <functional>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <ostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#include <ws2def.h> // NOTE needed for AF_INET6
|
||||||
|
#include <ws2ipdef.h> // NOTE needed for sockaddr_in6
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#else
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
std::string minio::http::Url::String() const {
|
std::string minio::http::Url::String() const {
|
||||||
if (host.empty()) return {};
|
if (host.empty()) return {};
|
||||||
@ -105,7 +133,8 @@ minio::http::Url minio::http::Url::Parse(std::string value) {
|
|||||||
if (!https && port == 80) port = 0;
|
if (!https && port == 80) port = 0;
|
||||||
if (https && port == 443) port = 0;
|
if (https && port == 443) port = 0;
|
||||||
|
|
||||||
return Url{https, host, port, path, query_string};
|
return Url(https, std::move(host), port, std::move(path),
|
||||||
|
std::move(query_string));
|
||||||
}
|
}
|
||||||
|
|
||||||
minio::error::Error minio::http::Response::ReadStatusCode() {
|
minio::error::Error minio::http::Response::ReadStatusCode() {
|
||||||
@ -248,7 +277,8 @@ size_t minio::http::Response::ResponseCallback(curlpp::Multi* const requests,
|
|||||||
|
|
||||||
// If data function is set and the request is successful, send data.
|
// If data function is set and the request is successful, send data.
|
||||||
if (datafunc != nullptr && status_code >= 200 && status_code <= 299) {
|
if (datafunc != nullptr && status_code >= 200 && status_code <= 299) {
|
||||||
DataFunctionArgs args{request, this, response_, userdata};
|
DataFunctionArgs args(request, this, std::string(this->response_),
|
||||||
|
userdata);
|
||||||
if (!datafunc(args)) requests->remove(request);
|
if (!datafunc(args)) requests->remove(request);
|
||||||
} else {
|
} else {
|
||||||
body = response_;
|
body = response_;
|
||||||
@ -259,7 +289,7 @@ size_t minio::http::Response::ResponseCallback(curlpp::Multi* const requests,
|
|||||||
|
|
||||||
// If data function is set and the request is successful, send data.
|
// If data function is set and the request is successful, send data.
|
||||||
if (datafunc != nullptr && status_code >= 200 && status_code <= 299) {
|
if (datafunc != nullptr && status_code >= 200 && status_code <= 299) {
|
||||||
DataFunctionArgs args{request, this, std::string(buffer, length), userdata};
|
DataFunctionArgs args(request, this, std::string(buffer, length), userdata);
|
||||||
if (!datafunc(args)) requests->remove(request);
|
if (!datafunc(args)) requests->remove(request);
|
||||||
} else {
|
} else {
|
||||||
body.append(buffer, length);
|
body.append(buffer, length);
|
||||||
@ -368,9 +398,9 @@ minio::http::Response minio::http::Request::execute() {
|
|||||||
while (!requests.perform(&left)) {
|
while (!requests.perform(&left)) {
|
||||||
}
|
}
|
||||||
while (left) {
|
while (left) {
|
||||||
fd_set fdread;
|
fd_set fdread{};
|
||||||
fd_set fdwrite;
|
fd_set fdwrite{};
|
||||||
fd_set fdexcep;
|
fd_set fdexcep{};
|
||||||
int maxfd = 0;
|
int maxfd = 0;
|
||||||
|
|
||||||
FD_ZERO(&fdread);
|
FD_ZERO(&fdread);
|
||||||
|
@ -17,22 +17,32 @@
|
|||||||
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "providers.h"
|
|
||||||
|
|
||||||
#include <INIReader.h>
|
#include <INIReader.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <list>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "signer.h"
|
#ifdef _WIN32
|
||||||
#include "utils.h"
|
#include <WinSock2.h>
|
||||||
|
#include <ws2def.h>
|
||||||
#ifndef _WIN32
|
#include <ws2tcpip.h>
|
||||||
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "credentials.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "signer.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
minio::error::Error minio::creds::checkLoopbackHost(const std::string& host) {
|
minio::error::Error minio::creds::checkLoopbackHost(const std::string& host) {
|
||||||
struct addrinfo hints = {};
|
struct addrinfo hints = {};
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
@ -82,8 +92,8 @@ minio::creds::Credentials minio::creds::ChainedProvider::Fetch() {
|
|||||||
minio::creds::StaticProvider::StaticProvider(std::string access_key,
|
minio::creds::StaticProvider::StaticProvider(std::string access_key,
|
||||||
std::string secret_key,
|
std::string secret_key,
|
||||||
std::string session_token) {
|
std::string session_token) {
|
||||||
this->creds_ = Credentials{error::SUCCESS, std::move(access_key),
|
this->creds_ = Credentials(error::SUCCESS, std::move(access_key),
|
||||||
std::move(secret_key), std::move(session_token)};
|
std::move(secret_key), std::move(session_token));
|
||||||
}
|
}
|
||||||
|
|
||||||
minio::creds::StaticProvider::~StaticProvider() {}
|
minio::creds::StaticProvider::~StaticProvider() {}
|
||||||
@ -105,8 +115,8 @@ minio::creds::EnvAwsProvider::EnvAwsProvider() {
|
|||||||
}
|
}
|
||||||
utils::GetEnv(session_token, "AWS_SESSION_TOKEN");
|
utils::GetEnv(session_token, "AWS_SESSION_TOKEN");
|
||||||
|
|
||||||
this->creds_ =
|
this->creds_ = Credentials(error::SUCCESS, std::move(access_key),
|
||||||
Credentials{error::SUCCESS, access_key, secret_key, session_token};
|
std::move(secret_key), std::move(session_token));
|
||||||
}
|
}
|
||||||
|
|
||||||
minio::creds::EnvAwsProvider::~EnvAwsProvider() {}
|
minio::creds::EnvAwsProvider::~EnvAwsProvider() {}
|
||||||
@ -121,7 +131,8 @@ minio::creds::EnvMinioProvider::EnvMinioProvider() {
|
|||||||
|
|
||||||
utils::GetEnv(access_key, "MINIO_ACCESS_KEY");
|
utils::GetEnv(access_key, "MINIO_ACCESS_KEY");
|
||||||
utils::GetEnv(secret_key, "MINIO_SECRET_KEY");
|
utils::GetEnv(secret_key, "MINIO_SECRET_KEY");
|
||||||
this->creds_ = Credentials{error::SUCCESS, access_key, secret_key};
|
this->creds_ =
|
||||||
|
Credentials(error::SUCCESS, std::move(access_key), std::move(secret_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
minio::creds::EnvMinioProvider::~EnvMinioProvider() {}
|
minio::creds::EnvMinioProvider::~EnvMinioProvider() {}
|
||||||
@ -379,7 +390,7 @@ minio::creds::Credentials minio::creds::IamAwsProvider::Fetch() {
|
|||||||
std::ifstream ifs(token_file);
|
std::ifstream ifs(token_file);
|
||||||
nlohmann::json json = nlohmann::json::parse(ifs);
|
nlohmann::json json = nlohmann::json::parse(ifs);
|
||||||
ifs.close();
|
ifs.close();
|
||||||
return Jwt{json["access_token"], json["expires_in"]};
|
return Jwt(std::move(json["access_token"]), json["expires_in"]);
|
||||||
},
|
},
|
||||||
url, 0, "", role_arn_, role_session_name_);
|
url, 0, "", role_arn_, role_session_name_);
|
||||||
creds_ = provider.Fetch();
|
creds_ = provider.Fetch();
|
||||||
|
@ -15,6 +15,23 @@
|
|||||||
|
|
||||||
#include "request.h"
|
#include "request.h"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <ostream>
|
||||||
|
#include <regex>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "credentials.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "signer.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#define EMPTY_SHA256 \
|
#define EMPTY_SHA256 \
|
||||||
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||||
|
|
||||||
@ -199,7 +216,8 @@ minio::error::Error minio::s3::BaseUrl::BuildUrl(
|
|||||||
return error::Error("empty bucket name for object name " + object_name);
|
return error::Error("empty bucket name for object name " + object_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
url = http::Url{https, host, port, "/", query_params.ToQueryString()};
|
url = http::Url(https, std::string(this->host), port, "/",
|
||||||
|
query_params.ToQueryString());
|
||||||
|
|
||||||
if (bucket_name.empty()) {
|
if (bucket_name.empty()) {
|
||||||
this->BuildListBucketsUrl(url, region);
|
this->BuildListBucketsUrl(url, region);
|
||||||
|
@ -15,6 +15,18 @@
|
|||||||
|
|
||||||
#include "response.h"
|
#include "response.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <curlpp/cURLpp.hpp>
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
|
#include <pugixml.hpp>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
minio::s3::Response::Response() {}
|
minio::s3::Response::Response() {}
|
||||||
|
|
||||||
minio::s3::Response::~Response() {}
|
minio::s3::Response::~Response() {}
|
||||||
@ -90,7 +102,7 @@ minio::s3::ListBucketsResponse minio::s3::ListBucketsResponse::ParseXML(
|
|||||||
creation_date = utils::UtcTime::FromISO8601UTC(value.c_str());
|
creation_date = utils::UtcTime::FromISO8601UTC(value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
buckets.push_back(Bucket{name, creation_date});
|
buckets.push_back(Bucket(std::move(name), std::move(creation_date)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return buckets;
|
return buckets;
|
||||||
|
@ -15,6 +15,15 @@
|
|||||||
|
|
||||||
#include "select.h"
|
#include "select.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <pugixml.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
void minio::s3::SelectHandler::Reset() {
|
void minio::s3::SelectHandler::Reset() {
|
||||||
prelude_.clear();
|
prelude_.clear();
|
||||||
prelude_read_ = false;
|
prelude_read_ = false;
|
||||||
|
@ -15,6 +15,17 @@
|
|||||||
|
|
||||||
#include "signer.h"
|
#include "signer.h"
|
||||||
|
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <openssl/hmac.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "http.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
const char* SIGN_V4_ALGORITHM = "AWS4-HMAC-SHA256";
|
const char* SIGN_V4_ALGORITHM = "AWS4-HMAC-SHA256";
|
||||||
|
|
||||||
std::string minio::signer::GetScope(const utils::UtcTime& time,
|
std::string minio::signer::GetScope(const utils::UtcTime& time,
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
#include "sse.h"
|
#include "sse.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
minio::s3::Sse::Sse() {}
|
minio::s3::Sse::Sse() {}
|
||||||
|
|
||||||
minio::s3::Sse::~Sse() {}
|
minio::s3::Sse::~Sse() {}
|
||||||
|
10
src/types.cc
10
src/types.cc
@ -15,6 +15,16 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <ostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
minio::s3::RetentionMode minio::s3::StringToRetentionMode(
|
minio::s3::RetentionMode minio::s3::StringToRetentionMode(
|
||||||
std::string_view str) noexcept {
|
std::string_view str) noexcept {
|
||||||
if (str == "GOVERNANCE") return RetentionMode::kGovernance;
|
if (str == "GOVERNANCE") return RetentionMode::kGovernance;
|
||||||
|
41
src/utils.cc
41
src/utils.cc
@ -15,11 +15,44 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#include <corecrt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utils.h"
|
#include <openssl/bio.h>
|
||||||
|
#include <openssl/buffer.h>
|
||||||
|
#include <openssl/crypto.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#include <openssl/types.h>
|
||||||
|
#include <zconf.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <algorithm>
|
||||||
|
#include <cctype>
|
||||||
|
#include <chrono>
|
||||||
|
#include <clocale>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
#include <curlpp/cURLpp.hpp>
|
||||||
|
#include <exception>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <ios>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <locale>
|
||||||
|
#include <map>
|
||||||
|
#include <ostream>
|
||||||
|
#include <regex>
|
||||||
|
#include <sstream>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "error.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
const std::string WEEK_DAYS[] = {"Sun", "Mon", "Tue", "Wed",
|
const std::string WEEK_DAYS[] = {"Sun", "Mon", "Tue", "Wed",
|
||||||
"Thu", "Fri", "Sat"};
|
"Thu", "Fri", "Sat"};
|
||||||
@ -370,7 +403,7 @@ minio::utils::UtcTime minio::utils::UtcTime::FromISO8601UTC(const char* value) {
|
|||||||
std::time_t secs = std::mktime(&t);
|
std::time_t secs = std::mktime(&t);
|
||||||
|
|
||||||
unsigned long ul = 0;
|
unsigned long ul = 0;
|
||||||
sscanf(rv, ".%lu", &ul);
|
static_cast<void>(sscanf(rv, ".%lu", &ul));
|
||||||
long usecs = (long)ul;
|
long usecs = (long)ul;
|
||||||
|
|
||||||
return UtcTime(secs, usecs);
|
return UtcTime(secs, usecs);
|
||||||
@ -563,7 +596,7 @@ minio::error::Error minio::utils::CalcPartInfo(long object_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (object_size >= 0) {
|
if (object_size >= 0) {
|
||||||
if (static_cast<unsigned long long>(object_size) > kMaxObjectSize) {
|
if (static_cast<uint64_t>(object_size) > kMaxObjectSize) {
|
||||||
return error::Error("object size " + std::to_string(object_size) +
|
return error::Error("object size " + std::to_string(object_size) +
|
||||||
" is not supported; maximum allowed 5TiB");
|
" is not supported; maximum allowed 5TiB");
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,33 @@
|
|||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
#include <chrono>
|
|
||||||
#include <random>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <ostream>
|
||||||
|
#include <random>
|
||||||
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <streambuf>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "args.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "providers.h"
|
||||||
|
#include "request.h"
|
||||||
|
#include "response.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
thread_local static std::mt19937 rg{std::random_device{}()};
|
thread_local static std::mt19937 rg{std::random_device{}()};
|
||||||
|
|
||||||
@ -534,7 +556,9 @@ class Tests {
|
|||||||
args.bucket = bucket_name_;
|
args.bucket = bucket_name_;
|
||||||
args.object = object_name;
|
args.object = object_name;
|
||||||
minio::s3::PutObjectResponse resp = client_.PutObject(args);
|
minio::s3::PutObjectResponse resp = client_.PutObject(args);
|
||||||
if (!resp) std::runtime_error("PutObject(): " + resp.Error().String());
|
if (!resp) {
|
||||||
|
throw std::runtime_error("PutObject(): " + resp.Error().String());
|
||||||
|
}
|
||||||
object_names.push_back(object_name);
|
object_names.push_back(object_name);
|
||||||
}
|
}
|
||||||
RemoveObjects(object_names);
|
RemoveObjects(object_names);
|
||||||
|
Reference in New Issue
Block a user