Class GrpcWebTrailers

java.lang.Object
com.linecorp.armeria.common.grpc.GrpcWebTrailers

@Deprecated @UnstableApi public final class GrpcWebTrailers extends Object
Deprecated.
Use GrpcWebTrailers instead.
Retrieves gRPC-Web trailers.
  • Method Details

    • get

      @Nullable public static @Nullable HttpHeaders get(RequestContext ctx)
      Deprecated.
      Returns the gRPC-Web trailers which was set to the specified RequestContext using set(RequestContext, HttpHeaders).

      A gRPC-Web response does not contain a separated trailers according to the gRPC-Web spec:

      • Trailers must be the last message of the response.
      • Trailers may be sent together with response headers, with no message in the body.
      That means the response trailers should be pulled out from AggregatedHttpResponse.headers()} or parsed from AggregatedHttpObject.content().

      This method is useful when RetryRuleWithContent needs GrpcHeaderNames.GRPC_STATUS to decide whether to retry. For example:

      
       GrpcClients.builder(grpcServerUri)
                  .decorator(RetryingClient.newDecorator(
                          RetryRuleWithContent.onResponse((ctx, response) -> {
                              // Note that we should aggregate the response to get the trailers.
                              return response.aggregate().thenApply(aggregated -> {
                                  HttpHeaders trailers = GrpcWebTrailers.get(ctx);
                                  // Retry if the 'grpc-status' is not equal to 0.
                                  return trailers != null && trailers.getInt(GrpcHeaderNames.GRPC_STATUS) != 0;
                              });
                          })))
                  .build(MyGrpcStub.class);
       
    • set

      public static void set(RequestContext ctx, HttpHeaders trailers)
      Deprecated.
      Sets the specified gRPC-Web trailers to the RequestContext.