/** * Converts the {@link AggregatedHttpMessage} into a new {@link HttpRequest} and closes the stream. */ static HttpRequest of(AggregatedHttpMessage message) { return of(message.headers(), message.content(), message.trailingHeaders()); }
/** * Converts the {@link AggregatedHttpMessage} into a new complete {@link HttpResponse}. */ static HttpResponse of(AggregatedHttpMessage res) { requireNonNull(res, "res"); final List<HttpHeaders> informationals = res.informationals(); final HttpHeaders headers = res.headers(); final HttpData content = res.content(); final HttpHeaders trailingHeaders = res.trailingHeaders(); if (informationals.isEmpty()) { return of(headers, content, trailingHeaders); } final int numObjects = informationals.size() + 1 /* headers */ + (!content.isEmpty() ? 1 : 0) + (!trailingHeaders.isEmpty() ? 1 : 0); final HttpObject[] objs = new HttpObject[numObjects]; int writerIndex = 0; for (HttpHeaders informational : informationals) { objs[writerIndex++] = informational; } objs[writerIndex++] = headers; if (!content.isEmpty()) { objs[writerIndex++] = content; } if (!trailingHeaders.isEmpty()) { objs[writerIndex] = trailingHeaders; } return new RegularFixedHttpResponse(objs); }
AggregatedHttpMessage grpcResponse, CompletableFuture<HttpResponse> res) { final HttpHeaders trailers = !grpcResponse.trailingHeaders().isEmpty() ? grpcResponse.trailingHeaders() : grpcResponse.headers(); final String grpcStatusCode = trailers.get(GrpcHeaderNames.GRPC_STATUS); final Status grpcStatus = Status.fromCodeValue(Integer.parseInt(grpcStatusCode));
final HttpHeaders trailingHeaders = res.trailingHeaders();
convertHeaders(req.trailingHeaders(), cHeaders);
final boolean trailingHeadersEmpty = res.trailingHeaders().isEmpty(); final HttpData content = res.content(); final boolean contentAndTrailingHeadersEmpty = content.isEmpty() && trailingHeadersEmpty; if (!trailingHeadersEmpty) { future = responseEncoder.writeHeaders( req.id(), req.streamId(), res.trailingHeaders(), true);
AggregatedHttpMessage grpcResponse, CompletableFuture<HttpResponse> res) { final HttpHeaders trailers = !grpcResponse.trailingHeaders().isEmpty() ? grpcResponse.trailingHeaders() : grpcResponse.headers(); final String grpcStatusCode = trailers.get(GrpcHeaderNames.GRPC_STATUS); final Status grpcStatus = Status.fromCodeValue(Integer.parseInt(grpcStatusCode));