diff --git a/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcEntityHelpers.scala b/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcEntityHelpers.scala index 75a7da03..128b53f8 100644 --- a/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcEntityHelpers.scala +++ b/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcEntityHelpers.scala @@ -74,7 +74,10 @@ object GrpcEntityHelpers { TrailerFrame(trailers = statusHeaders(status)) def trailer(status: Status, metadata: Metadata): TrailerFrame = - TrailerFrame(trailers = statusHeaders(status) ++ metadataHeaders(metadata)) + TrailerFrame(trailers = trailers(status, metadata)) + + def trailers(status: Status, metadata: Metadata): List[HttpHeader] = + statusHeaders(status) ++ metadataHeaders(metadata) def statusHeaders(status: Status): List[HttpHeader] = List(headers.`Status`(status.getCode.value.toString)) ++ Option(status.getDescription).map(d => diff --git a/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala b/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala index bb41a680..e686376d 100644 --- a/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala +++ b/runtime/src/main/scala/org/apache/pekko/grpc/internal/GrpcResponseHelpers.scala @@ -107,6 +107,12 @@ object GrpcResponseHelpers { entity = HttpEntity.Chunked(writer.contentType, entity)) } - def status(trailer: Trailers)(implicit writer: GrpcProtocolWriter): HttpResponse = - response(Source.single(writer.encodeFrame(GrpcEntityHelpers.trailer(trailer.status, trailer.metadata)))) + def status(trailer: Trailers)(implicit writer: GrpcProtocolWriter): HttpResponse = { + HttpResponse( + headers = + headers.`Message-Encoding`(writer.messageEncoding.name) :: + GrpcEntityHelpers.trailers(trailer.status, trailer.metadata), + entity = HttpEntity.empty(writer.contentType) + ) + } }