use of io.servicetalk.http.api.StatelessTrailersTransformer in project servicetalk by apple.
the class ContentLengthAndTrailersTest method setUp.
private void setUp(HttpProtocol protocol, String content) {
this.protocol = protocol;
this.content = content;
protocol(protocol.config);
serviceFilterFactory(service -> new StreamingHttpServiceFilter(service) {
@Override
public Single<StreamingHttpResponse> handle(final HttpServiceContext ctx, final StreamingHttpRequest request, final StreamingHttpResponseFactory responseFactory) {
// Use transform to simulate access to request trailers
return delegate().handle(ctx, request.transform(new StatelessTrailersTransformer<>()), responseFactory).map(response -> {
final HttpHeaders headers = request.headers();
if (headers.contains(CONTENT_LENGTH)) {
response.setHeader(CLIENT_CONTENT_LENGTH, mergeValues(headers.values(CONTENT_LENGTH)));
}
if (headers.contains(TRANSFER_ENCODING)) {
response.setHeader(CLIENT_TRANSFER_ENCODING, mergeValues(headers.values(TRANSFER_ENCODING)));
}
return response;
});
}
});
setUp(CACHED, CACHED_SERVER);
}
Aggregations