Package io.servicetalk.http.api
Class StreamingHttpResponses
java.lang.Object
io.servicetalk.http.api.StreamingHttpResponses
Factory methods for creating
StreamingHttpResponses.-
Method Summary
Modifier and TypeMethodDescriptionstatic StreamingHttpResponsenewResponse(HttpResponseStatus status, HttpProtocolVersion version, HttpHeaders headers, BufferAllocator allocator, HttpHeadersFactory headersFactory) Create a new instance using HTTP 1.1 with empty payload body.static StreamingHttpResponsenewTransportResponse(HttpResponseStatus status, HttpProtocolVersion version, HttpHeaders headers, BufferAllocator allocator, Publisher<Object> messageBody, boolean requireTrailerHeader, HttpHeadersFactory headersFactory) Deprecated.static StreamingHttpResponsenewTransportResponse(HttpResponseStatus status, HttpProtocolVersion version, HttpHeaders headers, BufferAllocator allocator, Publisher<Object> messageBody, boolean requireTrailerHeader, HttpHeadersFactory headersFactory, LongConsumer payloadSizeLimiter) Creates a newStreamingHttpResponsewhich is read from the transport, applying a limit to the size of the payload that may be buffered when the response is later aggregated.
-
Method Details
-
newResponse
public static StreamingHttpResponse newResponse(HttpResponseStatus status, HttpProtocolVersion version, HttpHeaders headers, BufferAllocator allocator, HttpHeadersFactory headersFactory) Create a new instance using HTTP 1.1 with empty payload body.- Parameters:
status- theHttpResponseStatusof the response.version- theHttpProtocolVersionof the response.headers- theHttpHeadersof the response.allocator- the allocator used for serialization purposes if necessary.headersFactory-HttpHeadersFactoryto use.- Returns:
- a new
StreamingHttpResponse.
-
newTransportResponse
@Deprecated public static StreamingHttpResponse newTransportResponse(HttpResponseStatus status, HttpProtocolVersion version, HttpHeaders headers, BufferAllocator allocator, Publisher<Object> messageBody, boolean requireTrailerHeader, HttpHeadersFactory headersFactory) Deprecated.UsenewTransportResponse(HttpResponseStatus, HttpProtocolVersion, HttpHeaders, BufferAllocator, Publisher, boolean, HttpHeadersFactory, LongConsumer)which allows bounding the size of the payload buffered during aggregation. This overload leaves the aggregated payload unbounded.Creates a newStreamingHttpResponsewhich is read from the transport. If the response contains trailers then the passedpayloadPublishershould also emitHttpHeadersbefore completion.- Parameters:
status- theHttpResponseStatusof the response.version- theHttpProtocolVersionof the response.headers- theHttpHeadersof the response.allocator- the allocator used for serialization purposes if necessary.messageBody- aPublisherfor payload that optionally emitsHttpHeadersif the response contains trailers.requireTrailerHeader-trueif Trailer header is required to accept trailers.falseassumes trailers may be present if other criteria allows.headersFactory-HttpHeadersFactoryto use.- Returns:
- a new
StreamingHttpResponse.
-
newTransportResponse
public static StreamingHttpResponse newTransportResponse(HttpResponseStatus status, HttpProtocolVersion version, HttpHeaders headers, BufferAllocator allocator, Publisher<Object> messageBody, boolean requireTrailerHeader, HttpHeadersFactory headersFactory, LongConsumer payloadSizeLimiter) Creates a newStreamingHttpResponsewhich is read from the transport, applying a limit to the size of the payload that may be buffered when the response is later aggregated. If the response contains trailers then the passedpayloadPublishershould also emitHttpHeadersbefore completion.- Parameters:
status- theHttpResponseStatusof the response.version- theHttpProtocolVersionof the response.headers- theHttpHeadersof the response.allocator- the allocator used for serialization purposes if necessary.messageBody- aPublisherfor payload that optionally emitsHttpHeadersif the response contains trailers.requireTrailerHeader-trueif Trailer header is required to accept trailers.falseassumes trailers may be present if other criteria allows.headersFactory-HttpHeadersFactoryto use.payloadSizeLimiter- invoked with the running aggregated payload size (in bytes) as the response is aggregated (e.g. viaStreamingHttpResponse.toResponse()); it may reject an oversized message by throwing aPayloadTooLargeException. Usesize -> { }to leave the payload unbounded.- Returns:
- a new
StreamingHttpResponse.
-
newTransportResponse(HttpResponseStatus, HttpProtocolVersion, HttpHeaders, BufferAllocator, Publisher, boolean, HttpHeadersFactory, LongConsumer)which allows bounding the size of the payload buffered during aggregation.