Class SseRequestImpl
java.lang.Object
kong.unirest.core.SseRequestImpl
- All Implemented Interfaces:
SseRequest
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe Accept header to send.Basic auth credentialsconnect()execute a synchronous Server Sent Event Stream Due to the nature of SSE this stream may remain open indefinitely meaning you may be blocked while attempting to collect the stream.connect(SseHandler handler) execute a SSE Event connection async.Add a simple cookie headercookie(Collection<Cookie> cookies) Add a collection of cookie headersAdd a simple cookie headergetUrl()Add a http header, HTTP supports multiple of the same header.headerReplace(String name, String value) Replace a header value or add it if it doesn't existAdd headers as a maplastEventId(String id) Sets the Last-Event-ID HTTP request header reports an EventSource object's last event ID string to the server when the user agent is to reestablish the connection.queryString(String name, Object value) add a query param to the url.queryString(String name, Collection<?> value) Add multiple param with the same param name. queryString("name", Arrays.asList("bob", "linda")) will result in ?queryString(Map<String, Object> parameters) Add query params as a map of name value pairsrouteParam(String name, String value) add a route param that replaces the matching {name} For example routeParam("name", "fred") will replace {name} in https://localhost/users/{user} to https://localhost/users/fredrouteParam(Map<String, Object> params) add a route param map that replaces the matching {name} For example routeParam(Map.of("name", "fred")) will replace {name} in https://localhost/users/{user} to https://localhost/users/fred
-
Field Details
-
headers
-
-
Constructor Details
-
SseRequestImpl
-
-
Method Details
-
routeParam
Description copied from interface:SseRequestadd a route param that replaces the matching {name} For example routeParam("name", "fred") will replace {name} in https://localhost/users/{user} to https://localhost/users/fred- Specified by:
routeParamin interfaceSseRequest- Parameters:
name- the name of the param (do not include curly braces {}value- the value to replace the placeholder with- Returns:
- this request builder
-
routeParam
Description copied from interface:SseRequestadd a route param map that replaces the matching {name} For example routeParam(Map.of("name", "fred")) will replace {name} in https://localhost/users/{user} to https://localhost/users/fred- Specified by:
routeParamin interfaceSseRequest- Parameters:
params- a map of path params- Returns:
- this request builder
-
basicAuth
Description copied from interface:SseRequestBasic auth credentials- Specified by:
basicAuthin interfaceSseRequest- Parameters:
username- the usernamepassword- the password- Returns:
- this request builder
-
accept
Description copied from interface:SseRequestThe Accept header to send. The default (and standard) is "text/event-stream"- Specified by:
acceptin interfaceSseRequest- Parameters:
value- a valid mime type for the Accept header- Returns:
- this request builder
-
header
Description copied from interface:SseRequestAdd a http header, HTTP supports multiple of the same header. This will continue to append new values- Specified by:
headerin interfaceSseRequest- Parameters:
name- name of the headervalue- value for the header- Returns:
- this request builder
-
headerReplace
Description copied from interface:SseRequestReplace a header value or add it if it doesn't exist- Specified by:
headerReplacein interfaceSseRequest- Parameters:
name- name of the headervalue- value for the header- Returns:
- this request builder
-
headers
Description copied from interface:SseRequestAdd headers as a map- Specified by:
headersin interfaceSseRequest- Parameters:
headerMap- a map of headers- Returns:
- this request builder
-
cookie
Description copied from interface:SseRequestAdd a simple cookie header- Specified by:
cookiein interfaceSseRequest- Parameters:
name- the name of the cookievalue- the value of the cookie- Returns:
- this request builder
-
cookie
Description copied from interface:SseRequestAdd a simple cookie header- Specified by:
cookiein interfaceSseRequest- Parameters:
cookie- a cookie- Returns:
- this request builder
-
cookie
Description copied from interface:SseRequestAdd a collection of cookie headers- Specified by:
cookiein interfaceSseRequest- Parameters:
cookies- a cookie- Returns:
- this request builder
-
queryString
Description copied from interface:SseRequestadd a query param to the url. The value will be URL-Encoded- Specified by:
queryStringin interfaceSseRequest- Parameters:
name- the name of the paramvalue- the value of the param- Returns:
- this request builder
-
queryString
Description copied from interface:SseRequestAdd multiple param with the same param name. queryString("name", Arrays.asList("bob", "linda")) will result in ?name=bob&name=linda- Specified by:
queryStringin interfaceSseRequest- Parameters:
name- the name of the paramvalue- a collection of values- Returns:
- this request builder
-
queryString
Description copied from interface:SseRequestAdd query params as a map of name value pairs- Specified by:
queryStringin interfaceSseRequest- Parameters:
parameters- a map of params- Returns:
- this request builder
-
lastEventId
Description copied from interface:SseRequestSets the Last-Event-ID HTTP request header reports an EventSource object's last event ID string to the server when the user agent is to reestablish the connection.- Specified by:
lastEventIdin interfaceSseRequest- Parameters:
id- the ID- Returns:
- this request builder
-
connect
Description copied from interface:SseRequestexecute a SSE Event connection async. Because these events are a stream they are processed async and take a handler you can use to consume the events- Specified by:
connectin interfaceSseRequest- Parameters:
handler- the SseHandler- Returns:
- a CompletableFuture which can be used to monitor if the task is complete or not
-
connect
Description copied from interface:SseRequestexecute a synchronous Server Sent Event Stream Due to the nature of SSE this stream may remain open indefinitely meaning you may be blocked while attempting to collect the stream. It is recommend you consume the stream rather than doing any action that requires it to stop.- Specified by:
connectin interfaceSseRequest- Returns:
- a stream of events
-
getHeaders
- Specified by:
getHeadersin interfaceSseRequest- Returns:
- the headers for the request
-
getUrl
- Specified by:
getUrlin interfaceSseRequest- Returns:
- the full URL if the request
-