diff --git a/bazel/repository_locations.bzl b/bazel/repository_locations.bzl index e882b6bef3a55..7f85c181f661c 100644 --- a/bazel/repository_locations.bzl +++ b/bazel/repository_locations.bzl @@ -505,13 +505,13 @@ REPOSITORY_LOCATIONS_SPEC = dict( project_name = "grpc-httpjson-transcoding", project_desc = "Library that supports transcoding so that HTTP/JSON can be converted to gRPC", project_url = "https://github.com/grpc-ecosystem/grpc-httpjson-transcoding", - version = "4d095f048889d4fc3b8d4579aa80ca4290319802", - sha256 = "7af66e0674340932683ab4f04ea6f03e2550849a54741738d94310b84d396a2c", + version = "22160afc7e67b9becce3198f8a6a321f01a3cef8", + sha256 = "d761b6442f600b628f5e420b601824757dfdbea6c12ac86cd59dbaa53d20d343", strip_prefix = "grpc-httpjson-transcoding-{version}", urls = ["https://github.com/grpc-ecosystem/grpc-httpjson-transcoding/archive/{version}.tar.gz"], use_category = ["dataplane_ext"], extensions = ["envoy.filters.http.grpc_json_transcoder"], - release_date = "2020-11-13", + release_date = "2021-01-06", cpe = "N/A", ), io_bazel_rules_go = dict( diff --git a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc index 557d1b755f472..43e275a5df4de 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc @@ -733,6 +733,41 @@ TEST_F(GrpcJsonTranscoderFilterTest, TranscodingUnaryWithHttpBodyAsOutput) { EXPECT_EQ(Http::FilterTrailersStatus::Continue, filter_.decodeTrailers(request_trailers)); } +TEST_F(GrpcJsonTranscoderFilterTest, TranscodingUnaryOnRootPath) { + Http::TestRequestHeaderMapImpl request_headers{{":method", "GET"}, {":path", "/"}}; + + EXPECT_CALL(decoder_callbacks_, clearRouteCache()); + + EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_.decodeHeaders(request_headers, false)); + EXPECT_EQ("application/grpc", request_headers.get_("content-type")); + EXPECT_EQ("/", request_headers.get_("x-envoy-original-path")); + EXPECT_EQ("GET", request_headers.get_("x-envoy-original-method")); + EXPECT_EQ("/bookstore.Bookstore/GetRoot", request_headers.get_(":path")); + EXPECT_EQ("trailers", request_headers.get_("te")); + + Http::TestResponseHeaderMapImpl response_headers{{"content-type", "application/grpc"}, + {":status", "200"}}; + + EXPECT_EQ(Http::FilterHeadersStatus::StopIteration, + filter_.encodeHeaders(response_headers, false)); + EXPECT_EQ("application/json", response_headers.get_("content-type")); + + google::api::HttpBody response; + response.set_content_type("text/html"); + response.set_data("

Hello, world!

"); + + auto response_data = Grpc::Common::serializeToGrpcFrame(response); + + EXPECT_EQ(Http::FilterDataStatus::StopIterationAndBuffer, + filter_.encodeData(*response_data, false)); + + EXPECT_EQ(response.content_type(), response_headers.get_("content-type")); + EXPECT_EQ(response.data(), response_data->toString()); + + Http::TestRequestTrailerMapImpl request_trailers; + EXPECT_EQ(Http::FilterTrailersStatus::Continue, filter_.decodeTrailers(request_trailers)); +} + TEST_F(GrpcJsonTranscoderFilterTest, TranscodingUnaryWithInvalidHttpBodyAsOutput) { Http::TestRequestHeaderMapImpl request_headers{{":method", "GET"}, {":path", "/echoResponseBodyPath"}}; diff --git a/test/proto/bookstore.proto b/test/proto/bookstore.proto index b3865ffe9d95a..6855e64443696 100644 --- a/test/proto/bookstore.proto +++ b/test/proto/bookstore.proto @@ -96,6 +96,11 @@ service Bookstore { get: "/indexStream" }; } + rpc GetRoot(google.protobuf.Empty) returns (google.api.HttpBody) { + option (google.api.http) = { + get: "/" + }; + } rpc PostBody(EchoBodyRequest) returns (google.protobuf.Empty) { option (google.api.http) = { post: "/postBody"