9 #include <boost/asio/ssl.hpp> 10 #include <boost/beast/core/flat_buffer.hpp> 11 #include <boost/beast/http/buffer_body.hpp> 12 #include <boost/beast/http/empty_body.hpp> 13 #include <boost/beast/http/parser.hpp> 15 #include "absl/types/optional.h" 17 #include "file/file.h" 18 #include "strings/stringpiece.h" 19 #include "util/gce/gce.h" 20 #include "util/status.h" 27 class HttpsClientPool;
43 using error_code = ::boost::system::error_code;
45 GCS(
const GCE& gce, ::boost::asio::ssl::context* ssl_cntx,
IoContext* io_context);
53 using ListObjectCb = std::function<void(
size_t, absl::string_view)>;
60 ReadObjectResult Read(absl::string_view bucket, absl::string_view path,
size_t ofs,
61 const strings::MutableByteRange& range);
66 absl::string_view* path);
69 static std::string
ToGcsPath(absl::string_view bucket, absl::string_view obj_path);
73 using Request = ::boost::beast::http::request<::boost::beast::http::empty_body>;
74 template <
typename Body>
using Response = ::boost::beast::http::response<Body>;
75 template <
typename Body>
using Parser = ::boost::beast::http::response_parser<Body>;
78 using ReusableParser = absl::optional<Parser<boost::beast::http::buffer_body>>;
82 std::string BuildGetObjUrl(absl::string_view bucket, absl::string_view path);
86 template <
typename RespBody>
util::Status SendWithToken(Request* req, Response<RespBody>* resp);
88 uint32_t native_handle();
90 std::string access_token_header_;
91 std::unique_ptr<http::HttpsClient> https_client_;
94 bool IsGcsPath(absl::string_view path);
125 const file::ReadonlyFile::Options& opts = file::ReadonlyFile::Options{});
ListObjectResult List(absl::string_view bucket, absl::string_view prefix, bool fs_mode, ListObjectCb cb)
static std::string ToGcsPath(absl::string_view bucket, absl::string_view obj_path)
Inverse function to SplitToBucketPath. Returns full gcs URI that starts with "gs://"".
std::function< void(size_t, absl::string_view)> ListObjectCb
Called with (size, key_name) pairs.
static bool SplitToBucketPath(absl::string_view input, absl::string_view *bucket, absl::string_view *path)