public class EventSourceResponse extends Response implements EventSource<java.lang.String>
Response this object must be close'd to
prevent resource leak.
The usage flow is as follows:
HttpClient.openEvents(Request, int)close()HttpClient.reopenEvents(Request, String, int) with last processed Event#id() and go to p.2EventSource.Event<D>ACCEPTED, BAD_GATEWAY, BAD_REQUEST, CONFLICT, CONTINUE, CREATED, EMPTY, EXPECTATION_FAILED, FORBIDDEN, FOUND, GATEWAY_TIMEOUT, GONE, HTTP_VERSION_NOT_SUPPORTED, INTERNAL_ERROR, LENGTH_REQUIRED, METHOD_NOT_ALLOWED, MOVED_PERMANENTLY, MULTIPLE_CHOICES, NO_CONTENT, NON_AUTHORITATIVE_INFORMATION, NOT_ACCEPTABLE, NOT_FOUND, NOT_IMPLEMENTED, NOT_MODIFIED, OK, PARTIAL_CONTENT, PAYMENT_REQUIRED, PRECONDITION_FAILED, PROXY_AUTHENTICATION_REQUIRED, REQUEST_ENTITY_TOO_LARGE, REQUEST_TIMEOUT, REQUEST_URI_TOO_LONG, REQUESTED_RANGE_NOT_SATISFIABLE, RESET_CONTENT, SEE_OTHER, SERVICE_UNAVAILABLE, SWITCHING_PROTOCOLS, TEMPORARY_REDIRECT, UNAUTHORIZED, UNSUPPORTED_MEDIA_TYPE, UPGRADE_REQUIRED, USE_PROXY| Constructor and Description |
|---|
EventSourceResponse(java.lang.String resultCode) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
EventSource.Event<java.lang.String> |
poll()
Waits for the next SSE and returns an event.
|
addHeader, getBody, getBodyUtf8, getHeader, getHeaderCount, getHeaders, getStatus, json, ok, ok, redirect, setBody, toBytes, toStringpublic EventSource.Event<java.lang.String> poll() throws java.io.IOException, HttpException
EventSourceEventSource.Event.isEmpty() before processingpoll in interface EventSource<java.lang.String>java.io.IOException - an I/O exception occurredHttpException - an incorrect HTTP request receivedpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOException