ServerResponse for sending
Server-Sent Events.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final Consumer | |
| private final Duration |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ServerResponse | |
| private static HttpHeaders | |
| private static MultiValueMap | |
| protected ModelAndView | writeToInternal(HttpServletRequest request, HttpServletResponse response, ServerResponse.
Implements abstract org.
|
| sseConsumer | back to summary |
|---|---|
| private final Consumer<ServerResponse. | |
| timeout | back to summary |
|---|---|
| private final Duration timeout
| |
| SseServerResponse | back to summary |
|---|---|
| private SseServerResponse(Consumer<ServerResponse. | |
| create | back to summary |
|---|---|
| public static ServerResponse create(Consumer<ServerResponse. | |
| createHeaders | back to summary |
|---|---|
| private static HttpHeaders createHeaders() | |
| emptyCookies | back to summary |
|---|---|
| private static MultiValueMap | |
| writeToInternal | back to summary |
|---|---|
| protected ModelAndView writeToInternal(HttpServletRequest request, HttpServletResponse response, ServerResponse. Implements abstract org. | |
| Modifier and Type | Class and Description |
|---|---|
| private static class | SseServerResponse.
Wrap to silently ignore header changes HttpMessageConverter's that would otherwise cause HttpHeaders to raise exceptions. |
| Modifier and Type | Field and Description |
|---|---|
| private final StringBuilder | |
| private final DeferredResult | |
| private final HttpHeaders | |
| private final List | |
| private static final byte[] | |
| private final ServerHttpResponse | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | DefaultSseBuilder(HttpServletResponse response, ServerResponse.
|
| Modifier and Type | Method and Description |
|---|---|
| private byte[] | |
| public ServerResponse. | comment(String
the comment comment)Implements org. Add an SSE comment. |
| public void | complete()
Implements org. Completes the event stream. |
| public void | data(Object
the object to send as data object)Implements org. Add an SSE "data" line for the given object and sends the built server-sent event to the client. |
| public void | error(Throwable
the throwable to dispatch t)Implements org. Completes the event stream with the given error. |
| public ServerResponse. | event(String
the event name eventName)Implements org. Add an SSE "event" line. |
| private ServerResponse. | |
| public ServerResponse. | id(String
the event identifier id)Implements org. Add an SSE "id" line. |
| public ServerResponse. | onComplete(Runnable
the callback to invoked on completion onCompletion)Implements org. Register a callback to be invoked when the SSE request completes. |
| public ServerResponse. | onError(Consumer<Throwable>
the callback to invoke on error onError)Implements org. Register a callback to be invoked when an error occurs during SSE processing. |
| public ServerResponse. | onTimeout(Runnable
the callback to invoke on timeout onTimeout)Implements org. Register a callback to be invoked when an SSE request times out. |
| public ServerResponse. | retry(Duration
the duration to convert into millis duration)Implements org. Add an SSE "retry" line. |
| public void | send(Object
the object to send object)Implements org. Sends the given object as a server-sent event. |
| public void | send()
Implements org. Sends the buffered content as a server-sent event, without data. |
| private void | |
| private void |
| builder | back to summary |
|---|---|
| private final StringBuilder builder | |
| deferredResult | back to summary |
|---|---|
| private final DeferredResult<?> deferredResult | |
| httpHeaders | back to summary |
|---|---|
| private final HttpHeaders httpHeaders | |
| messageConverters | back to summary |
|---|---|
| private final List<HttpMessageConverter<?>> messageConverters | |
| NL_NL | back to summary |
|---|---|
| private static final byte[] NL_NL | |
| outputMessage | back to summary |
|---|---|
| private final ServerHttpResponse outputMessage | |
| sendFailed | back to summary |
|---|---|
| private boolean sendFailed | |
| DefaultSseBuilder | back to summary |
|---|---|
| public DefaultSseBuilder(HttpServletResponse response, ServerResponse. | |
| builderBytes | back to summary |
|---|---|
| private byte[] builderBytes() | |
| comment | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Add an SSE comment.
| |
| complete | back to summary |
|---|---|
| public void complete() Implements org. Doc from org. Completes the event stream.
| |
| data | back to summary |
|---|---|
| public void data(Object object) throws IOException Implements org. Doc from org. Add an SSE "data" line for the given object and sends the built server-sent event to the client. Strings will be sent as UTF-8 encoded bytes, and other objects will be converted into JSON using message converters.
| |
| error | back to summary |
|---|---|
| public void error(Throwable t) Implements org. Doc from org. Completes the event stream with the given error. The throwable is dispatched back into Spring MVC, and passed to its exception handling mechanism. Since the response has been committed by this point, the response status can not change. | |
| event | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Add an SSE "event" line.
| |
| field | back to summary |
|---|---|
| private ServerResponse. | |
| id | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Add an SSE "id" line.
| |
| onComplete | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Register a callback to be invoked when the SSE request completes.
| |
| onError | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Register a callback to be invoked when an error occurs during SSE processing.
| |
| onTimeout | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Register a callback to be invoked when an SSE request times out.
| |
| retry | back to summary |
|---|---|
| public ServerResponse. Implements org. Doc from org. Add an SSE "retry" line.
| |
| send | back to summary |
|---|---|
| public void send(Object object) throws IOException Implements org. Doc from org. Sends the given object as a server-sent event. Strings will be sent as UTF-8 encoded bytes, and other objects will be converted into JSON using message converters. This convenience method has the same effect as
| |
| send | back to summary |
|---|---|
| public void send() throws IOException Implements org. Doc from org. Sends the buffered content as a server-sent event, without data.
Only the
| |
| writeObject | back to summary |
|---|---|
private void writeObject(Object data) throws IOException
| |
| writeString | back to summary |
|---|---|
| private void writeString(String string) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| private final HttpHeaders |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public HttpHeaders | getHeaders()
Overrides org. Implements org. Return the headers of this message. |
| mutableHeaders | back to summary |
|---|---|
| private final HttpHeaders mutableHeaders | |
| MutableHeadersServerHttpResponse | back to summary |
|---|---|
| public MutableHeadersServerHttpResponse(ServerHttpResponse delegate, HttpHeaders headers) | |
| getHeaders | back to summary |
|---|---|
| public HttpHeaders getHeaders() Overrides org. Implements org. Doc from org. Return the headers of this message.
| |