Package kong.unirest.core
Class WebSocketRequestImpl
- java.lang.Object
-
- kong.unirest.core.WebSocketRequestImpl
-
- All Implemented Interfaces:
WebSocketRequest
public class WebSocketRequestImpl extends Object implements WebSocketRequest
-
-
Constructor Summary
Constructors Constructor Description WebSocketRequestImpl(Config config, String url)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebSocketRequestaccept(String value)The Accept header to send (e.g. application/jsonWebSocketRequestbasicAuth(String username, String password)Basic auth credentialsWebSocketResponseconnect(WebSocket.Listener listener)WebSocketRequestcookie(String name, String value)Add a simple cookie headerWebSocketRequestcookie(Collection<Cookie> cookies)Add a collection of cookie headersWebSocketRequestcookie(Cookie cookie)Add a simple cookie headerHeadersgetHeaders()StringgetUrl()WebSocketRequestheader(String name, String value)Add a http header, HTTP supports multiple of the same header.WebSocketRequestheaderReplace(String name, String value)Replace a header value or add it if it doesn't existWebSocketRequestheaders(Map<String,String> headerMap)Add headers as a mapWebSocketRequestqueryString(String name, Object value)add a query param to the url.WebSocketRequestqueryString(String name, Collection<?> value)Add multiple param with the same param name.WebSocketRequestqueryString(Map<String,Object> parameters)Add query params as a map of name value pairsWebSocketRequestresponseEncoding(String encoding)The encoding to expect the response to be for cases where the server fails to respond with the proper encodingWebSocketRequestrouteParam(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/fredWebSocketRequestrouteParam(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 Detail
-
headers
protected Headers headers
-
config
protected final Config config
-
method
protected HttpMethod method
-
url
protected Path url
-
-
Method Detail
-
routeParam
public WebSocketRequest routeParam(String name, String value)
Description copied from interface:WebSocketRequestadd 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 interfaceWebSocketRequest- 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
public WebSocketRequest routeParam(Map<String,Object> params)
Description copied from interface:WebSocketRequestadd 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 interfaceWebSocketRequest- Parameters:
params- a map of path params- Returns:
- this request builder
-
basicAuth
public WebSocketRequest basicAuth(String username, String password)
Description copied from interface:WebSocketRequestBasic auth credentials- Specified by:
basicAuthin interfaceWebSocketRequest- Parameters:
username- the usernamepassword- the password- Returns:
- this request builder
-
accept
public WebSocketRequest accept(String value)
Description copied from interface:WebSocketRequestThe Accept header to send (e.g. application/json- Specified by:
acceptin interfaceWebSocketRequest- Parameters:
value- a valid mime type for the Accept header- Returns:
- this request builder
-
responseEncoding
public WebSocketRequest responseEncoding(String encoding)
Description copied from interface:WebSocketRequestThe encoding to expect the response to be for cases where the server fails to respond with the proper encoding- Specified by:
responseEncodingin interfaceWebSocketRequest- Parameters:
encoding- a valid mime type for the Accept header- Returns:
- this request builder
-
header
public WebSocketRequest header(String name, String value)
Description copied from interface:WebSocketRequestAdd a http header, HTTP supports multiple of the same header. This will continue to append new values- Specified by:
headerin interfaceWebSocketRequest- Parameters:
name- name of the headervalue- value for the header- Returns:
- this request builder
-
headerReplace
public WebSocketRequest headerReplace(String name, String value)
Description copied from interface:WebSocketRequestReplace a header value or add it if it doesn't exist- Specified by:
headerReplacein interfaceWebSocketRequest- Parameters:
name- name of the headervalue- value for the header- Returns:
- this request builder
-
headers
public WebSocketRequest headers(Map<String,String> headerMap)
Description copied from interface:WebSocketRequestAdd headers as a map- Specified by:
headersin interfaceWebSocketRequest- Parameters:
headerMap- a map of headers- Returns:
- this request builder
-
cookie
public WebSocketRequest cookie(String name, String value)
Description copied from interface:WebSocketRequestAdd a simple cookie header- Specified by:
cookiein interfaceWebSocketRequest- Parameters:
name- the name of the cookievalue- the value of the cookie- Returns:
- this request builder
-
cookie
public WebSocketRequest cookie(Cookie cookie)
Description copied from interface:WebSocketRequestAdd a simple cookie header- Specified by:
cookiein interfaceWebSocketRequest- Parameters:
cookie- a cookie- Returns:
- this request builder
-
cookie
public WebSocketRequest cookie(Collection<Cookie> cookies)
Description copied from interface:WebSocketRequestAdd a collection of cookie headers- Specified by:
cookiein interfaceWebSocketRequest- Parameters:
cookies- a cookie- Returns:
- this request builder
-
queryString
public WebSocketRequest queryString(String name, Object value)
Description copied from interface:WebSocketRequestadd a query param to the url. The value will be URL-Encoded- Specified by:
queryStringin interfaceWebSocketRequest- Parameters:
name- the name of the paramvalue- the value of the param- Returns:
- this request builder
-
queryString
public WebSocketRequest queryString(String name, Collection<?> value)
Description copied from interface:WebSocketRequestAdd multiple param with the same param name. queryString("name", Arrays.asList("bob", "linda")) will result in ?name=bob&name=linda- Specified by:
queryStringin interfaceWebSocketRequest- Parameters:
name- the name of the paramvalue- a collection of values- Returns:
- this request builder
-
queryString
public WebSocketRequest queryString(Map<String,Object> parameters)
Description copied from interface:WebSocketRequestAdd query params as a map of name value pairs- Specified by:
queryStringin interfaceWebSocketRequest- Parameters:
parameters- a map of params- Returns:
- this request builder
-
connect
public WebSocketResponse connect(WebSocket.Listener listener)
- Specified by:
connectin interfaceWebSocketRequest
-
getHeaders
public Headers getHeaders()
- Specified by:
getHeadersin interfaceWebSocketRequest
-
getUrl
public String getUrl()
- Specified by:
getUrlin interfaceWebSocketRequest
-
-