Interface StreamingResponse
-
public interface StreamingResponseAllows streaming a response directly, similar toStreamingOutput. UnlikeStreamingOutput, though,StreamingResponseallows HTTP headers to be set prior to streaming. Setting headers inwrite(javax.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, java.io.OutputStream)instead of on theResponsewrapping thisStreamingResponse, allows setting headers only if the operations leading up to streaming bytes actually succeed.Note that, if just-in-time headers are not needed, it's preferable to use the standard
StreamingOutputinterface instead.- Since:
- 9.5.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidwrite(@NotNull javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, @NotNull OutputStream outputStream)Writes the entity payload to the response, optionally setting additional HTTP headers first.
-
-
-
Method Detail
-
write
void write(@NotNull @NotNull javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, @NotNull @NotNull OutputStream outputStream) throws IOException, javax.ws.rs.WebApplicationExceptionWrites the entity payload to the response, optionally setting additional HTTP headers first.Additional headers must be set before the first byte is written to the provided
OutputStream. When the first byte is written pending headers are flushed, and any subsequent headers will be ignored.- Parameters:
httpHeaders- a mutable map of HTTP headers, allowing new headers to be set (HTTP headers can only be set prior to writing any bytes to the providedOutputStream.)outputStream- the stream to write the entity payload to- Throws:
IOException- if the entity cannot be written to the streamjavax.ws.rs.WebApplicationException- if an unexpected error occurs and the overallResponseshould be changed (The response can only be changed if this exception is thrown prior to writing any bytes to the providedOutputStream.)
-
-