@@ -644,54 +644,56 @@ Future<StorageListResult> StorageReferenceInternal::List(
644644 future_api->SafeAlloc <StorageListResult>(kStorageReferenceFnList );
645645
646646 std::string page_token_str = page_token ? page_token : " " ;
647- auto send_request_funct{[&, max_results_per_page,
648- page_token_str]() -> BlockingResponse* {
649- auto * future_api = future ();
650- auto handle = future_api->SafeAlloc <StorageListResult>(
651- kStorageReferenceFnListInternal );
647+ auto send_request_funct{
648+ [&, max_results_per_page, page_token_str]() -> BlockingResponse* {
649+ auto * future_api = future ();
650+ auto handle = future_api->SafeAlloc <StorageListResult>(
651+ kStorageReferenceFnListInternal );
652652
653- ReturnedListResponse* response =
654- new ReturnedListResponse (handle, future_api, storage_);
653+ ReturnedListResponse* response =
654+ new ReturnedListResponse (handle, future_api, storage_);
655655
656- storage::internal::Request* request = new storage::internal::Request ();
657-
658- // For listing, we need the bucket URL: [scheme]://[host]/v0/b/[bucket]/o
659- // We cannot use storageUri_.AsHttpMetadataUrl() directly because it appends the encoded path
660- std::string url = storage_->get_scheme ();
661- url += " ://" ;
662- url += storage_->get_host ();
663- url += " :" ;
664- url += std::to_string (storage_->get_port ());
665- url += " /v0/b/" ;
666- url += bucket ();
667- url += " /o" ;
668-
669- // The prefix must end with a slash to be treated as a directory by the REST
670- // API.
671- std::string prefix = storageUri_.GetPath ().str ();
672- if (!prefix.empty () && prefix.back () != ' /' ) {
673- prefix += " /" ;
674- }
656+ storage::internal::Request* request = new storage::internal::Request ();
675657
676- // Append query parameters
677- std::string delimiter = " /" ;
678- url += " ?delimiter=" + delimiter;
679- if (!prefix.empty ()) {
680- url += " &prefix=" + rest::util::EncodeUrl (prefix);
681- }
682- if (max_results_per_page > 0 ) {
683- url += " &maxResults=" + std::to_string (max_results_per_page);
684- }
685- if (!page_token_str.empty ()) {
686- url += " &pageToken=" + rest::util::EncodeUrl (page_token_str);
687- }
658+ // For listing, we need the bucket URL:
659+ // [scheme]://[host]/v0/b/[bucket]/o We cannot use
660+ // storageUri_.AsHttpMetadataUrl() directly because it appends the
661+ // encoded path
662+ std::string url = storage_->get_scheme ();
663+ url += " ://" ;
664+ url += storage_->get_host ();
665+ url += " :" ;
666+ url += std::to_string (storage_->get_port ());
667+ url += " /v0/b/" ;
668+ url += bucket ();
669+ url += " /o" ;
670+
671+ // The prefix must end with a slash to be treated as a directory by the
672+ // REST API.
673+ std::string prefix = storageUri_.GetPath ().str ();
674+ if (!prefix.empty () && prefix.back () != ' /' ) {
675+ prefix += " /" ;
676+ }
688677
689- PrepareRequestBlocking (request, url.c_str (), rest::util::kGet );
678+ // Append query parameters
679+ std::string delimiter = " /" ;
680+ url += " ?delimiter=" + delimiter;
681+ if (!prefix.empty ()) {
682+ url += " &prefix=" + rest::util::EncodeUrl (prefix);
683+ }
684+ if (max_results_per_page > 0 ) {
685+ url += " &maxResults=" + std::to_string (max_results_per_page);
686+ }
687+ if (!page_token_str.empty ()) {
688+ url += " &pageToken=" + rest::util::EncodeUrl (page_token_str);
689+ }
690690
691- RestCall (request, request->notifier (), response, handle.get (), nullptr ,
692- nullptr );
693- return response;
694- }};
691+ PrepareRequestBlocking (request, url.c_str (), rest::util::kGet );
692+
693+ RestCall (request, request->notifier (), response, handle.get (), nullptr ,
694+ nullptr );
695+ return response;
696+ }};
695697
696698 SendRequestWithRetry (kStorageReferenceFnListInternal , send_request_funct,
697699 handle, storage_->max_operation_retry_time ());
0 commit comments