Skip to content

Commit d39ef3b

Browse files
committed
update users of rest library types
1 parent ae0f7b4 commit d39ef3b

File tree

9 files changed

+23
-21
lines changed

9 files changed

+23
-21
lines changed

generator/integration_tests/tests/golden_thing_admin_rest_metadata_decorator_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ TEST(ThingAdminRestMetadataDecoratorTest, DropDatabaseExplicitRoutingMatch) {
312312
EXPECT_THAT(context.GetHeader("x-goog-quota-user"), IsEmpty());
313313
EXPECT_THAT(context.GetHeader("x-server-timeout"), IsEmpty());
314314
EXPECT_THAT(
315-
context.GetHeader("x-goog-request-params")[0],
315+
context.GetHeader("x-goog-request-params").values().front(),
316316
AllOf(
317317
HasSubstr(std::string("project=projects%2Fmy_project")),
318318
HasSubstr(std::string("instance=instances%2Fmy_instance")),

google/cloud/bigquery/v2/minimal/internal/log_wrapper.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ Result LogWrapper(Functor&& functor, rest_internal::RestContext& context,
3838
TracingOptions const& options) {
3939
auto formatter = [options](std::string* out, auto const& header) {
4040
auto const* delim = options.single_line_mode() ? "&" : "\n";
41-
absl::StrAppend(
42-
out, " { name: \"", header.first, "\" value: \"",
43-
internal::DebugString(absl::StrJoin(header.second, delim), options),
44-
"\" }");
41+
absl::StrAppend(out, " { name: \"", std::string_view{header.first},
42+
"\" value: \"",
43+
internal::DebugString(
44+
absl::StrJoin(header.second.values(), delim), options),
45+
"\" }");
4546
};
4647
GCP_LOG(DEBUG) << where << "() << "
4748
<< request.DebugString(request_name, options) << ", Context {"

google/cloud/bigquery/v2/minimal/internal/rest_stub_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ StatusOr<rest_internal::RestRequest> PrepareRestRequest(
4848
if (!rest_context.headers().empty()) {
4949
for (auto const& h : rest_context.headers()) {
5050
if (!h.second.empty()) {
51-
rest_request->AddHeader(h.first, absl::StrJoin(h.second, "&"));
51+
rest_request->AddHeader(h.first, absl::StrJoin(h.second.values(), "&"));
5252
}
5353
}
5454
}

google/cloud/bigquery/v2/minimal/testing/metadata_test_utils.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ static auto const kUserProject = "test-only-project";
3030
static auto const kQuotaUser = "test-quota-user";
3131

3232
void VerifyMetadataContext(rest_internal::RestContext& context) {
33-
EXPECT_THAT(context.GetHeader("x-goog-api-client"),
33+
EXPECT_THAT(context.GetHeader("x-goog-api-client").values(),
3434
ElementsAre(internal::HandCraftedLibClientHeader()));
35-
EXPECT_THAT(context.GetHeader("x-goog-request-params"), IsEmpty());
36-
EXPECT_THAT(context.GetHeader("x-goog-user-project"),
35+
EXPECT_THAT(context.GetHeader("x-goog-request-params").values(), IsEmpty());
36+
EXPECT_THAT(context.GetHeader("x-goog-user-project").values(),
3737
ElementsAre(kUserProject));
38-
EXPECT_THAT(context.GetHeader("x-goog-quota-user"), ElementsAre(kQuotaUser));
39-
EXPECT_THAT(context.GetHeader("x-server-timeout"), ElementsAre("3.141"));
38+
EXPECT_THAT(context.GetHeader("x-goog-quota-user").values(),
39+
ElementsAre(kQuotaUser));
40+
EXPECT_THAT(context.GetHeader("x-server-timeout").values(),
41+
ElementsAre("3.141"));
4042
}
4143

4244
Options GetMetadataOptions() {

google/cloud/internal/oauth2_minimal_iam_credentials_rest.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "google/cloud/common_options.h"
1717
#include "google/cloud/internal/api_client_header.h"
1818
#include "google/cloud/internal/format_time_point.h"
19+
#include "google/cloud/internal/http_header.h"
1920
#include "google/cloud/internal/json_parsing.h"
2021
#include "google/cloud/internal/make_status.h"
2122
#include "google/cloud/internal/oauth2_credentials.h"
@@ -50,7 +51,7 @@ MinimalIamCredentialsRestStub::GenerateAccessToken(
5051
if (!auth_header) return std::move(auth_header).status();
5152

5253
rest_internal::RestRequest rest_request;
53-
rest_request.AddHeader(auth_header.value());
54+
rest_request.AddHeader(rest_internal::HttpHeader(auth_header.value()));
5455
rest_request.AddHeader("Content-Type", "application/json");
5556
rest_request.SetPath(MakeRequestPath(request));
5657
nlohmann::json payload{

google/cloud/storage/internal/grpc/configure_client_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void AddIdempotencyToken(grpc::ClientContext& ctx,
2828
auto const& headers = context.headers();
2929
auto const l = headers.find(kIdempotencyTokenHeader);
3030
if (l != headers.end()) {
31-
for (auto const& v : l->second) {
31+
for (auto const& v : l->second.values()) {
3232
ctx.AddMetadata(kIdempotencyTokenHeader, v);
3333
}
3434
}

google/cloud/storage/internal/rest/stub_test.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,9 @@ TEST(RestStubTest, GlobalCustomHeadersAppearInRequestTest) {
178178
google::cloud::rest_internal::RestRequest const& request) {
179179
auto const& headers = request.headers();
180180
EXPECT_THAT(headers,
181-
Contains(Pair("custom-header-1",
182-
std::vector<std::string>{"value1"})));
181+
Contains(Pair("custom-header-1", ElementsAre("value1"))));
183182
EXPECT_THAT(headers,
184-
Contains(Pair("custom-header-2",
185-
std::vector<std::string>{"value2"})));
186-
183+
Contains(Pair("custom-header-2", ElementsAre("value2"))));
187184
return PermanentError();
188185
});
189186
auto stub = std::make_unique<RestStub>(global_opts, mock_client, mock_client);

google/cloud/storage/testing/retry_tests.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ void CaptureIdempotencyToken(std::vector<std::string>& tokens,
121121
auto const& headers = context.headers();
122122
auto l = headers.find(kIdempotencyTokenHeader);
123123
if (l == headers.end()) return;
124-
tokens.insert(tokens.end(), l->second.begin(), l->second.end());
124+
auto values = l->second.values();
125+
tokens.insert(tokens.end(), values.begin(), values.end());
125126
}
126127

127128
void CaptureAuthorityOption(std::vector<std::string>& authority,

google/cloud/storage/tests/service_account_credentials_integration_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ TEST_F(ServiceAccountCredentialsTest, UserInfoOAuth2) {
5656
auto factory = [c = sa_creds]() {
5757
auto authorization = c->GetToken(std::chrono::system_clock::now());
5858
if (!authorization) return rest_internal::RestRequest();
59-
return rest_internal::RestRequest().AddHeader(
60-
std::make_pair("Authorization", "Bearer " + authorization->token));
59+
return rest_internal::RestRequest().AddHeader(rest_internal::HttpHeader(
60+
"Authorization", "Bearer " + authorization->token));
6161
};
6262

6363
auto response = RetryHttpGet(kUrl, factory);

0 commit comments

Comments
 (0)