Class WebSocketHttpHeaders

java.lang.Object
org.springframework.http.HttpHeaders
org.springframework.web.socket.WebSocketHttpHeaders
All Implemented Interfaces:
Serializable, Map<String,List<String>>, org.springframework.util.MultiValueMap<String,String>

public class WebSocketHttpHeaders extends org.springframework.http.HttpHeaders
An HttpHeaders variant that adds support for the HTTP headers defined by the WebSocket specification RFC 6455.
Since:
4.0
Author:
Rossen Stoyanchev
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface java.util.Map

    Map.Entry<K extends Object,V extends Object>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     

    Fields inherited from class org.springframework.http.HttpHeaders

    ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_PATCH, ACCEPT_RANGES, ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_RANGE, CONTENT_TYPE, COOKIE, DATE, EMPTY, ETAG, EXPECT, EXPIRES, FROM, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LINK, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SERVER, SET_COOKIE, SET_COOKIE2, TE, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new instance.
    WebSocketHttpHeaders(org.springframework.http.HttpHeaders headers)
    Create an instance that wraps the given pre-existing HttpHeaders and also propagate all changes to it.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String headerName, String headerValue)
    Add the given, single header value under the given name.
    void
     
    boolean
     
    boolean
     
     
    boolean
    equals(Object other)
     
    void
    forEach(BiConsumer<? super String,? super List<String>> action)
     
    get(Object key)
     
    getFirst(String headerName)
    Return the first header value for the given header name, if any.
    Returns the value of the Sec-WebSocket-Accept header.
    Returns the value of the Sec-WebSocket-Extensions header.
    Returns the value of the Sec-WebSocket-Key header.
    Returns the value of the Sec-WebSocket-Key header.
    Returns the value of the Sec-WebSocket-Version header.
    int
     
    boolean
     
     
    put(String key, List<String> value)
     
    void
    putAll(Map<? extends String,? extends List<String>> m)
     
    putIfAbsent(String key, List<String> value)
     
     
    void
    set(String headerName, String headerValue)
    Set the given, single header value under the given name.
    void
     
    void
    setSecWebSocketAccept(String secWebSocketAccept)
    Sets the (new) value of the Sec-WebSocket-Accept header.
    void
    Sets the (new) value(s) of the Sec-WebSocket-Extensions header.
    void
    setSecWebSocketKey(String secWebSocketKey)
    Sets the (new) value of the Sec-WebSocket-Key header.
    void
    setSecWebSocketProtocol(String secWebSocketProtocol)
    Sets the (new) value of the Sec-WebSocket-Protocol header.
    void
    setSecWebSocketProtocol(List<String> secWebSocketProtocols)
    Sets the (new) value of the Sec-WebSocket-Protocol header.
    void
    setSecWebSocketVersion(String secWebSocketVersion)
    Sets the (new) value of the Sec-WebSocket-Version header.
    int
     
     
     
     

    Methods inherited from class org.springframework.http.HttpHeaders

    addAll, addAll, clearContentHeaders, encodeBasicAuth, formatHeaders, getAccept, getAcceptCharset, getAcceptLanguage, getAcceptLanguageAsLocales, getAcceptPatch, getAccessControlAllowCredentials, getAccessControlAllowHeaders, getAccessControlAllowMethods, getAccessControlAllowOrigin, getAccessControlExposeHeaders, getAccessControlMaxAge, getAccessControlRequestHeaders, getAccessControlRequestMethod, getAllow, getCacheControl, getConnection, getContentDisposition, getContentLanguage, getContentLength, getContentType, getDate, getETag, getETagValuesAsList, getExpires, getFieldValues, getFirstDate, getFirstZonedDateTime, getHost, getIfMatch, getIfModifiedSince, getIfNoneMatch, getIfUnmodifiedSince, getLastModified, getLocation, getOrEmpty, getOrigin, getPragma, getRange, getUpgrade, getValuesAsList, getVary, readOnlyHttpHeaders, readOnlyHttpHeaders, setAccept, setAcceptCharset, setAcceptLanguage, setAcceptLanguageAsLocales, setAcceptPatch, setAccessControlAllowCredentials, setAccessControlAllowHeaders, setAccessControlAllowMethods, setAccessControlAllowOrigin, setAccessControlExposeHeaders, setAccessControlMaxAge, setAccessControlMaxAge, setAccessControlRequestHeaders, setAccessControlRequestMethod, setAllow, setBasicAuth, setBasicAuth, setBasicAuth, setBearerAuth, setCacheControl, setCacheControl, setConnection, setConnection, setContentDisposition, setContentDispositionFormData, setContentLanguage, setContentLength, setContentType, setDate, setDate, setDate, setDate, setETag, setExpires, setExpires, setExpires, setHost, setIfMatch, setIfMatch, setIfModifiedSince, setIfModifiedSince, setIfModifiedSince, setIfNoneMatch, setIfNoneMatch, setIfUnmodifiedSince, setIfUnmodifiedSince, setIfUnmodifiedSince, setInstant, setLastModified, setLastModified, setLastModified, setLocation, setOrigin, setPragma, setRange, setUpgrade, setVary, setZonedDateTime, toCommaDelimitedString, writableHttpHeaders

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.Map

    compute, computeIfAbsent, computeIfPresent, getOrDefault, merge, remove, replace, replace, replaceAll

    Methods inherited from interface org.springframework.util.MultiValueMap

    addIfAbsent
  • Field Details

  • Constructor Details

    • WebSocketHttpHeaders

      public WebSocketHttpHeaders()
      Create a new instance.
    • WebSocketHttpHeaders

      public WebSocketHttpHeaders(org.springframework.http.HttpHeaders headers)
      Create an instance that wraps the given pre-existing HttpHeaders and also propagate all changes to it.
      Parameters:
      headers - the HTTP headers to wrap
  • Method Details

    • setSecWebSocketAccept

      public void setSecWebSocketAccept(@Nullable String secWebSocketAccept)
      Sets the (new) value of the Sec-WebSocket-Accept header.
      Parameters:
      secWebSocketAccept - the value of the header
    • getSecWebSocketAccept

      @Nullable public String getSecWebSocketAccept()
      Returns the value of the Sec-WebSocket-Accept header.
      Returns:
      the value of the header
    • getSecWebSocketExtensions

      public List<WebSocketExtension> getSecWebSocketExtensions()
      Returns the value of the Sec-WebSocket-Extensions header.
      Returns:
      the value of the header
    • setSecWebSocketExtensions

      public void setSecWebSocketExtensions(List<WebSocketExtension> extensions)
      Sets the (new) value(s) of the Sec-WebSocket-Extensions header.
      Parameters:
      extensions - the values for the header
    • setSecWebSocketKey

      public void setSecWebSocketKey(@Nullable String secWebSocketKey)
      Sets the (new) value of the Sec-WebSocket-Key header.
      Parameters:
      secWebSocketKey - the value of the header
    • getSecWebSocketKey

      @Nullable public String getSecWebSocketKey()
      Returns the value of the Sec-WebSocket-Key header.
      Returns:
      the value of the header
    • setSecWebSocketProtocol

      public void setSecWebSocketProtocol(String secWebSocketProtocol)
      Sets the (new) value of the Sec-WebSocket-Protocol header.
      Parameters:
      secWebSocketProtocol - the value of the header
    • setSecWebSocketProtocol

      public void setSecWebSocketProtocol(List<String> secWebSocketProtocols)
      Sets the (new) value of the Sec-WebSocket-Protocol header.
      Parameters:
      secWebSocketProtocols - the value of the header
    • getSecWebSocketProtocol

      public List<String> getSecWebSocketProtocol()
      Returns the value of the Sec-WebSocket-Key header.
      Returns:
      the value of the header
    • setSecWebSocketVersion

      public void setSecWebSocketVersion(@Nullable String secWebSocketVersion)
      Sets the (new) value of the Sec-WebSocket-Version header.
      Parameters:
      secWebSocketVersion - the value of the header
    • getSecWebSocketVersion

      @Nullable public String getSecWebSocketVersion()
      Returns the value of the Sec-WebSocket-Version header.
      Returns:
      the value of the header
    • getFirst

      @Nullable public String getFirst(String headerName)
      Return the first header value for the given header name, if any.
      Specified by:
      getFirst in interface org.springframework.util.MultiValueMap<String,String>
      Overrides:
      getFirst in class org.springframework.http.HttpHeaders
      Parameters:
      headerName - the header name
      Returns:
      the first header value; or null
    • add

      public void add(String headerName, @Nullable String headerValue)
      Add the given, single header value under the given name.
      Specified by:
      add in interface org.springframework.util.MultiValueMap<String,String>
      Overrides:
      add in class org.springframework.http.HttpHeaders
      Parameters:
      headerName - the header name
      headerValue - the header value
      Throws:
      UnsupportedOperationException - if adding headers is not supported
      See Also:
    • set

      public void set(String headerName, @Nullable String headerValue)
      Set the given, single header value under the given name.
      Specified by:
      set in interface org.springframework.util.MultiValueMap<String,String>
      Overrides:
      set in class org.springframework.http.HttpHeaders
      Parameters:
      headerName - the header name
      headerValue - the header value
      Throws:
      UnsupportedOperationException - if adding headers is not supported
      See Also:
    • setAll

      public void setAll(Map<String,String> values)
      Specified by:
      setAll in interface org.springframework.util.MultiValueMap<String,String>
      Overrides:
      setAll in class org.springframework.http.HttpHeaders
    • toSingleValueMap

      public Map<String,String> toSingleValueMap()
      Specified by:
      toSingleValueMap in interface org.springframework.util.MultiValueMap<String,String>
      Overrides:
      toSingleValueMap in class org.springframework.http.HttpHeaders
    • size

      public int size()
      Specified by:
      size in interface Map<String,List<String>>
      Overrides:
      size in class org.springframework.http.HttpHeaders
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,List<String>>
      Overrides:
      isEmpty in class org.springframework.http.HttpHeaders
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,List<String>>
      Overrides:
      containsKey in class org.springframework.http.HttpHeaders
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,List<String>>
      Overrides:
      containsValue in class org.springframework.http.HttpHeaders
    • get

      public List<String> get(Object key)
      Specified by:
      get in interface Map<String,List<String>>
      Overrides:
      get in class org.springframework.http.HttpHeaders
    • put

      public List<String> put(String key, List<String> value)
      Specified by:
      put in interface Map<String,List<String>>
      Overrides:
      put in class org.springframework.http.HttpHeaders
    • remove

      public List<String> remove(Object key)
      Specified by:
      remove in interface Map<String,List<String>>
      Overrides:
      remove in class org.springframework.http.HttpHeaders
    • putAll

      public void putAll(Map<? extends String,? extends List<String>> m)
      Specified by:
      putAll in interface Map<String,List<String>>
      Overrides:
      putAll in class org.springframework.http.HttpHeaders
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,List<String>>
      Overrides:
      clear in class org.springframework.http.HttpHeaders
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,List<String>>
      Overrides:
      keySet in class org.springframework.http.HttpHeaders
    • values

      public Collection<List<String>> values()
      Specified by:
      values in interface Map<String,List<String>>
      Overrides:
      values in class org.springframework.http.HttpHeaders
    • entrySet

      public Set<Map.Entry<String,List<String>>> entrySet()
      Specified by:
      entrySet in interface Map<String,List<String>>
      Overrides:
      entrySet in class org.springframework.http.HttpHeaders
    • forEach

      public void forEach(BiConsumer<? super String,? super List<String>> action)
      Specified by:
      forEach in interface Map<String,List<String>>
      Overrides:
      forEach in class org.springframework.http.HttpHeaders
    • putIfAbsent

      public List<String> putIfAbsent(String key, List<String> value)
      Specified by:
      putIfAbsent in interface Map<String,List<String>>
      Overrides:
      putIfAbsent in class org.springframework.http.HttpHeaders
    • equals

      public boolean equals(@Nullable Object other)
      Specified by:
      equals in interface Map<String,List<String>>
      Overrides:
      equals in class org.springframework.http.HttpHeaders
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,List<String>>
      Overrides:
      hashCode in class org.springframework.http.HttpHeaders
    • toString

      public String toString()
      Overrides:
      toString in class org.springframework.http.HttpHeaders