Skip to content

Add HTTP cancellation support #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions examples/BucketExists.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -42,8 +41,8 @@ int main(int argc, char* argv[]) {
std::cout << "my-bucket does not exist" << std::endl;
}
} else {
std::cout << "unable to do bucket existence check; " << resp.GetError()
<< std::endl;
std::cout << "unable to do bucket existence check; "
<< resp.Error().String() << std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/ComposeObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand Down Expand Up @@ -53,7 +52,8 @@ int main(int argc, char* argv[]) {
if (resp) {
std::cout << "my-object is successfully created" << std::endl;
} else {
std::cout << "unable to compose object; " << resp.GetError() << std::endl;
std::cout << "unable to compose object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/CopyObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -45,7 +44,8 @@ int main(int argc, char* argv[]) {
std::cout << "my-object is successfully created from "
<< "my-src-bucket/my-src-object" << std::endl;
} else {
std::cout << "unable to do copy object; " << resp.GetError() << std::endl;
std::cout << "unable to do copy object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/DownloadObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -41,7 +40,8 @@ int main(int argc, char* argv[]) {
std::cout << "my-object is successfully downloaded to my-object.csv"
<< std::endl;
} else {
std::cout << "unable to download object; " << resp.GetError() << std::endl;
std::cout << "unable to download object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
11 changes: 5 additions & 6 deletions examples/GetObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -31,9 +30,9 @@ int main(int argc, char* argv[]) {
minio::s3::GetObjectArgs args;
args.bucket = "my-bucket";
args.object = "my-object";
args.data_callback = [](minio::http::DataCallbackArgs args) -> size_t {
std::cout << std::string(args.buffer, args.length);
return args.size * args.length;
args.datafunc = [](minio::http::DataFunctionArgs args) -> bool {
std::cout << args.datachunk;
return true;
};

// Call get object.
Expand All @@ -44,7 +43,7 @@ int main(int argc, char* argv[]) {
std::cout << std::endl
<< "data of my-object is received successfully" << std::endl;
} else {
std::cout << "unable to get object; " << resp.GetError() << std::endl;
std::cout << "unable to get object; " << resp.Error().String() << std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/ListBuckets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -37,7 +36,8 @@ int main(int argc, char* argv[]) {
<< bucket.creation_date.ToHttpHeaderValue() << std::endl;
}
} else {
std::cout << "unable to list buckets; " << resp.GetError() << std::endl;
std::cout << "unable to list buckets; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/ListObjects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand Down Expand Up @@ -57,7 +56,8 @@ int main(int argc, char* argv[]) {
<< std::endl;
std::cout << "---" << std::endl;
} else {
std::cout << "unable to listobjects; " << item.GetError() << std::endl;
std::cout << "unable to listobjects; " << item.Error().String()
<< std::endl;
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/MakeBucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -38,7 +37,8 @@ int main(int argc, char* argv[]) {
if (resp) {
std::cout << "my-bucket is created successfully" << std::endl;
} else {
std::cout << "unable to create bucket; " << resp.GetError() << std::endl;
std::cout << "unable to create bucket; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/PutObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -41,7 +40,8 @@ int main(int argc, char* argv[]) {
if (resp) {
std::cout << "my-object is successfully created" << std::endl;
} else {
std::cout << "unable to do put object; " << resp.GetError() << std::endl;
std::cout << "unable to do put object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/RemoveBucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -38,7 +37,8 @@ int main(int argc, char* argv[]) {
if (resp) {
std::cout << "my-bucket is removed successfully" << std::endl;
} else {
std::cout << "unable to remove bucket; " << resp.GetError() << std::endl;
std::cout << "unable to remove bucket; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/RemoveObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -39,7 +38,8 @@ int main(int argc, char* argv[]) {
if (resp) {
std::cout << "my-object is removed successfully" << std::endl;
} else {
std::cout << "unable to remove object; " << resp.GetError() << std::endl;
std::cout << "unable to remove object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/StatObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand Down Expand Up @@ -70,7 +69,8 @@ int main(int argc, char* argv[]) {
<< std::endl;
}
} else {
std::cout << "unable to get stat object; " << resp.GetError() << std::endl;
std::cout << "unable to get stat object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions examples/UploadObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

int main(int argc, char* argv[]) {
// Create S3 base URL.
minio::http::BaseUrl base_url;
base_url.SetHost("play.min.io");
minio::s3::BaseUrl base_url("play.min.io");

// Create credential provider.
minio::creds::StaticProvider provider(
Expand All @@ -41,7 +40,8 @@ int main(int argc, char* argv[]) {
std::cout << "my-object.csv is successfully uploaded to my-object"
<< std::endl;
} else {
std::cout << "unable to upload object; " << resp.GetError() << std::endl;
std::cout << "unable to upload object; " << resp.Error().String()
<< std::endl;
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions include/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ struct DownloadObjectArgs : public ObjectReadArgs {
}; // struct DownloadObjectArgs

struct GetObjectArgs : public ObjectConditionalReadArgs {
http::DataCallback data_callback;
void *user_arg = NULL;
http::DataFunction datafunc;
void *userdata = NULL;

error::Error Validate();
}; // struct GetObjectArgs
Expand Down
4 changes: 2 additions & 2 deletions include/baseclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ utils::Multimap GetCommonListObjectsQueryParams(std::string& delimiter,
*/
class BaseClient {
protected:
http::BaseUrl& base_url_;
BaseUrl& base_url_;
creds::Provider* provider_ = NULL;
std::map<std::string, std::string> region_map_;
bool debug_ = false;
bool ignore_cert_check_ = false;
std::string user_agent_ = DEFAULT_USER_AGENT;

public:
BaseClient(http::BaseUrl& base_url, creds::Provider* provider = NULL);
BaseClient(BaseUrl& base_url, creds::Provider* provider = NULL);

void Debug(bool flag) { debug_ = flag; }

Expand Down
2 changes: 1 addition & 1 deletion include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Client : public BaseClient {
char* buf);

public:
Client(http::BaseUrl& base_url, creds::Provider* provider = NULL);
Client(BaseUrl& base_url, creds::Provider* provider = NULL);
ComposeObjectResponse ComposeObject(ComposeObjectArgs args);
CopyObjectResponse CopyObject(CopyObjectArgs args);
DownloadObjectResponse DownloadObject(DownloadObjectArgs args);
Expand Down
2 changes: 1 addition & 1 deletion include/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Error {

public:
Error() {}
Error(std::string_view msg) { msg_ = std::string(msg); }
Error(std::string_view msg) { this->msg_ = std::string(msg); }
std::string String() { return msg_; }
operator bool() const { return !msg_.empty(); }
}; // class Error
Expand Down
Loading