Class SseRequestImpl

java.lang.Object
kong.unirest.core.SseRequestImpl
All Implemented Interfaces:
SseRequest

public class SseRequestImpl extends Object implements SseRequest
  • Field Details

    • headers

      protected Headers headers
  • Constructor Details

    • SseRequestImpl

      public SseRequestImpl(Config config, String url)
  • Method Details

    • routeParam

      public SseRequest routeParam(String name, String value)
      Description copied from interface: SseRequest
      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/fred
      Specified by:
      routeParam in interface SseRequest
      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 SseRequest routeParam(Map<String,Object> params)
      Description copied from interface: SseRequest
      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
      Specified by:
      routeParam in interface SseRequest
      Parameters:
      params - a map of path params
      Returns:
      this request builder
    • basicAuth

      public SseRequest basicAuth(String username, String password)
      Description copied from interface: SseRequest
      Basic auth credentials
      Specified by:
      basicAuth in interface SseRequest
      Parameters:
      username - the username
      password - the password
      Returns:
      this request builder
    • accept

      public SseRequest accept(String value)
      Description copied from interface: SseRequest
      The Accept header to send. The default (and standard) is "text/event-stream"
      Specified by:
      accept in interface SseRequest
      Parameters:
      value - a valid mime type for the Accept header
      Returns:
      this request builder
    • header

      public SseRequest header(String name, String value)
      Description copied from interface: SseRequest
      Add a http header, HTTP supports multiple of the same header. This will continue to append new values
      Specified by:
      header in interface SseRequest
      Parameters:
      name - name of the header
      value - value for the header
      Returns:
      this request builder
    • headerReplace

      public SseRequest headerReplace(String name, String value)
      Description copied from interface: SseRequest
      Replace a header value or add it if it doesn't exist
      Specified by:
      headerReplace in interface SseRequest
      Parameters:
      name - name of the header
      value - value for the header
      Returns:
      this request builder
    • headers

      public SseRequest headers(Map<String,String> headerMap)
      Description copied from interface: SseRequest
      Add headers as a map
      Specified by:
      headers in interface SseRequest
      Parameters:
      headerMap - a map of headers
      Returns:
      this request builder
    • cookie

      public SseRequest cookie(String name, String value)
      Description copied from interface: SseRequest
      Add a simple cookie header
      Specified by:
      cookie in interface SseRequest
      Parameters:
      name - the name of the cookie
      value - the value of the cookie
      Returns:
      this request builder
    • cookie

      public SseRequest cookie(Cookie cookie)
      Description copied from interface: SseRequest
      Add a simple cookie header
      Specified by:
      cookie in interface SseRequest
      Parameters:
      cookie - a cookie
      Returns:
      this request builder
    • cookie

      public SseRequest cookie(Collection<Cookie> cookies)
      Description copied from interface: SseRequest
      Add a collection of cookie headers
      Specified by:
      cookie in interface SseRequest
      Parameters:
      cookies - a cookie
      Returns:
      this request builder
    • queryString

      public SseRequest queryString(String name, Object value)
      Description copied from interface: SseRequest
      add a query param to the url. The value will be URL-Encoded
      Specified by:
      queryString in interface SseRequest
      Parameters:
      name - the name of the param
      value - the value of the param
      Returns:
      this request builder
    • queryString

      public SseRequest queryString(String name, Collection<?> value)
      Description copied from interface: SseRequest
      Add multiple param with the same param name. queryString("name", Arrays.asList("bob", "linda")) will result in ?name=bob&name=linda
      Specified by:
      queryString in interface SseRequest
      Parameters:
      name - the name of the param
      value - a collection of values
      Returns:
      this request builder
    • queryString

      public SseRequest queryString(Map<String,Object> parameters)
      Description copied from interface: SseRequest
      Add query params as a map of name value pairs
      Specified by:
      queryString in interface SseRequest
      Parameters:
      parameters - a map of params
      Returns:
      this request builder
    • lastEventId

      public SseRequest lastEventId(String id)
      Description copied from interface: SseRequest
      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.
      Specified by:
      lastEventId in interface SseRequest
      Parameters:
      id - the ID
      Returns:
      this request builder
    • connect

      public CompletableFuture<Void> connect(SseHandler handler)
      Description copied from interface: SseRequest
      execute 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:
      connect in interface SseRequest
      Parameters:
      handler - the SseHandler
      Returns:
      a CompletableFuture which can be used to monitor if the task is complete or not
    • connect

      public Stream<Event> connect()
      Description copied from interface: SseRequest
      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. It is recommend you consume the stream rather than doing any action that requires it to stop.
      Specified by:
      connect in interface SseRequest
      Returns:
      a stream of events
    • getHeaders

      public Headers getHeaders()
      Specified by:
      getHeaders in interface SseRequest
      Returns:
      the headers for the request
    • getUrl

      public String getUrl()
      Specified by:
      getUrl in interface SseRequest
      Returns:
      the full URL if the request