类 HTTPHeaders


  • public class HTTPHeaders
    extends Object
    The http headers. This class is thread-safe.
    作者:
    Liu Dong
    • 方法详细资料

      • ofHttpHeaders

        public static HTTPHeaders ofHttpHeaders​(HttpHeaders httpHeaders)
        Construct a headers, from immutable jdk http client headers.
        参数:
        httpHeaders - the http headers
        返回:
        Headers
      • of

        public static HTTPHeaders of​(Collection<? extends HTTPHeader> headers)
        Construct headers from a Collection of header.
        参数:
        headers - the header collection
        返回:
        Headers
      • getHeaders

        public List<String> getHeaders​(String name)
        Get headers by name. If not exists, return empty list
      • getHeader

        public Optional<String> getHeader​(String name)
        Get the first header value matched name.
      • getLongHeader

        public OptionalLong getLongHeader​(String name)
        Get header value as long.
      • allHeaders

        public Map<String,​List<String>> allHeaders()
        Get all header as Map
        返回:
        immutable map of headers. return empty map if do not has any header.
      • contentType

        public Optional<ContentType> contentType()
        Get content type set in http header. If do not set Content-Type header, or parse header error, return empty Optional.
        返回:
        the charset
      • cookies

        public HTTPCookies cookies()
        Get cookies in this header.
        返回:
        a immutable list of cookies