aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/ext/filters/http/client/http_client_filter.c4
-rw-r--r--src/core/ext/filters/http/server/http_server_filter.c6
-rw-r--r--test/cpp/interop/client.cc4
-rw-r--r--test/cpp/interop/interop_client.cc20
4 files changed, 26 insertions, 8 deletions
diff --git a/src/core/ext/filters/http/client/http_client_filter.c b/src/core/ext/filters/http/client/http_client_filter.c
index 019f2ead1d..b896c7e7bb 100644
--- a/src/core/ext/filters/http/client/http_client_filter.c
+++ b/src/core/ext/filters/http/client/http_client_filter.c
@@ -334,10 +334,8 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
*/
char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice);
/* safe to use strlen since base64_encode will always add '\0' */
- size_t path_length = strlen(t) + 1;
- *(t + path_length) = '\0';
path_with_query_slice =
- grpc_slice_sub(path_with_query_slice, 0, path_length);
+ grpc_slice_sub(path_with_query_slice, 0, strlen(t));
/* substitute previous path with the new path+query */
grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices(
diff --git a/src/core/ext/filters/http/server/http_server_filter.c b/src/core/ext/filters/http/server/http_server_filter.c
index 952728b352..ff857878e4 100644
--- a/src/core/ext/filters/http/server/http_server_filter.c
+++ b/src/core/ext/filters/http/server/http_server_filter.c
@@ -240,9 +240,9 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
const int k_url_safe = 1;
grpc_slice_buffer_add(
&calld->read_slice_buffer,
- grpc_base64_decode(exec_ctx,
- (const char *)GRPC_SLICE_START_PTR(query_slice),
- k_url_safe));
+ grpc_base64_decode_with_len(
+ exec_ctx, (const char *)GRPC_SLICE_START_PTR(query_slice),
+ GRPC_SLICE_LENGTH(query_slice), k_url_safe));
grpc_slice_buffer_stream_init(&calld->read_stream,
&calld->read_slice_buffer, 0);
calld->seen_path_with_query = true;
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 369413e6a1..6f1d910304 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -163,8 +163,8 @@ int main(int argc, char** argv) {
std::bind(&grpc::testing::InteropClient::DoUnimplementedMethod, &client);
actions["unimplemented_service"] =
std::bind(&grpc::testing::InteropClient::DoUnimplementedService, &client);
- // actions["cacheable_unary"] =
- // std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client);
+ actions["cacheable_unary"] =
+ std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client);
UpdateActions(&actions);
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 55ba324cc7..0e79c5e4b4 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -918,6 +918,26 @@ bool InteropClient::DoCacheableUnary() {
// second response is a cached copy of the first response
GPR_ASSERT(response2.payload().body() == response1.payload().body());
+ // Request 3
+ // Modify the request body so it will not get a cache hit
+ ts = gpr_now(GPR_CLOCK_PRECISE);
+ timestamp = std::to_string((long long unsigned)ts.tv_nsec);
+ SimpleRequest request1;
+ request1.mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
+ ClientContext context3;
+ SimpleResponse response3;
+ context3.set_cacheable(true);
+ context3.AddMetadata("x-user-ip", "1.2.3.4");
+ Status s3 =
+ serviceStub_.Get()->CacheableUnaryCall(&context3, request1, &response3);
+ if (!AssertStatusOk(s3)) {
+ return false;
+ }
+ gpr_log(GPR_DEBUG, "response 3 payload: %s",
+ response3.payload().body().c_str());
+
+ // Check that the response is different from the previous response.
+ GPR_ASSERT(response3.payload().body() != response1.payload().body());
return true;
}