Class GrpcWebTrailers
java.lang.Object
com.linecorp.armeria.common.grpc.protocol.GrpcWebTrailers
Retrieves gRPC-Web trailers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable com.linecorp.armeria.common.HttpHeadersget(com.linecorp.armeria.common.RequestContext ctx) Returns the gRPC-Web trailers which was set to the specifiedRequestContextusingset(RequestContext, HttpHeaders).static voidset(com.linecorp.armeria.common.RequestContext ctx, com.linecorp.armeria.common.HttpHeaders trailers) Sets the specified gRPC-Web trailers to theRequestContext.
-
Method Details
-
get
@Nullable public static @Nullable com.linecorp.armeria.common.HttpHeaders get(com.linecorp.armeria.common.RequestContext ctx) Returns the gRPC-Web trailers which was set to the specifiedRequestContextusingset(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.
AggregatedHttpResponse.headers()} or parsed fromAggregatedHttpObject.content().This method is useful when
RetryRuleWithContentneedsGrpcHeaderNames.GRPC_STATUSto decide whether to retry. For example:Clients.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(com.linecorp.armeria.common.RequestContext ctx, com.linecorp.armeria.common.HttpHeaders trailers) Sets the specified gRPC-Web trailers to theRequestContext.
-