Class EmptyHttpHeaders

  • All Implemented Interfaces:
    HttpHeaders, java.lang.Iterable<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>>

    public final class EmptyHttpHeaders
    extends java.lang.Object
    implements HttpHeaders
    HttpHeaders which are always empty and does not allow modification.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      HttpHeaders add​(HttpHeaders headers)
      Adds all header names and values of headers to this object.
      HttpHeaders add​(java.lang.CharSequence name, java.lang.CharSequence value)
      Adds a new header with the specified name and value.
      HttpHeaders add​(java.lang.CharSequence name, java.lang.CharSequence... values)
      Adds new headers with the specified name and values.
      HttpHeaders add​(java.lang.CharSequence name, java.lang.Iterable<? extends java.lang.CharSequence> values)
      Adds new headers with the specified name and values.
      HttpHeaders addCookie​(HttpCookiePair cookie)
      Adds a cookie.
      HttpHeaders addSetCookie​(HttpSetCookie cookie)
      Adds a set-cookie.
      HttpHeaders clear()
      Removes all headers.
      boolean contains​(java.lang.CharSequence name, java.lang.CharSequence value)
      Returns true if a header with the name and value exists, false otherwise.
      boolean containsIgnoreCase​(java.lang.CharSequence name, java.lang.CharSequence value)
      Returns true if a header with the name and value exists, false otherwise.
      boolean equals​(java.lang.Object o)  
      java.lang.CharSequence get​(java.lang.CharSequence name)
      Returns the value of a header with the specified name.
      java.lang.CharSequence get​(java.lang.CharSequence name, java.lang.CharSequence defaultValue)
      Returns the value of a header with the specified name.
      java.lang.CharSequence getAndRemove​(java.lang.CharSequence name)
      Returns the value of a header with the specified name and removes it from this object.
      HttpCookiePair getCookie​(java.lang.CharSequence name)
      Gets a cookie identified by name.
      java.util.Iterator<? extends HttpCookiePair> getCookiesIterator()
      Gets all the cookies.
      java.util.Iterator<? extends HttpCookiePair> getCookiesIterator​(java.lang.CharSequence name)
      Gets the cookies with the same name.
      HttpSetCookie getSetCookie​(java.lang.CharSequence name)
      Gets a set-cookie identified by name.
      java.util.Iterator<? extends HttpSetCookie> getSetCookiesIterator()
      Gets all the set-cookies.
      java.util.Iterator<? extends HttpSetCookie> getSetCookiesIterator​(java.lang.CharSequence name)
      Gets the set-cookies with the same name.
      java.util.Iterator<? extends HttpSetCookie> getSetCookiesIterator​(java.lang.CharSequence name, java.lang.CharSequence domain, java.lang.CharSequence path)
      Gets the set-cookies with the same name.
      int hashCode()  
      boolean isEmpty()
      Returns true if HttpHeaders.size() equals 0.
      java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>> iterator()  
      java.util.Set<? extends java.lang.CharSequence> names()
      Returns a Set of all header names in this object.
      boolean remove​(java.lang.CharSequence name)
      Removes all headers with the specified name.
      boolean remove​(java.lang.CharSequence name, java.lang.CharSequence value)
      Removes specific value(s) from the specified header name.
      boolean removeCookies​(java.lang.CharSequence name)
      Removes all cookie identified by name.
      boolean removeIgnoreCase​(java.lang.CharSequence name, java.lang.CharSequence value)
      Removes specific value(s) from the specified header name.
      boolean removeSetCookies​(java.lang.CharSequence name)
      Removes all set-cookie identified by name.
      boolean removeSetCookies​(java.lang.CharSequence name, java.lang.CharSequence domain, java.lang.CharSequence path)
      Removes all set-cookie identified by name.
      HttpHeaders replace​(HttpHeaders headers)
      Removes all header names contained in headers from this object, and then adds all headers contained in headers.
      HttpHeaders set​(HttpHeaders headers)
      Clears the current header entries and copies all header entries of the specified headers object.
      HttpHeaders set​(java.lang.CharSequence name, java.lang.CharSequence value)
      Sets a header with the specified name and value.
      HttpHeaders set​(java.lang.CharSequence name, java.lang.CharSequence... values)
      Sets a header with the specified name and values.
      HttpHeaders set​(java.lang.CharSequence name, java.lang.Iterable<? extends java.lang.CharSequence> values)
      Sets a new header with the specified name and values.
      int size()
      Returns the number of headers in this object.
      java.lang.String toString()
      Returns a String representation of this HttpHeaders.
      java.lang.String toString​(java.util.function.BiFunction<? super java.lang.CharSequence,​? super java.lang.CharSequence,​java.lang.CharSequence> filter)
      Builds a string which represents all the content in this HttpHeaders in which sensitive headers can be filtered via filter.
      java.util.Iterator<? extends java.lang.CharSequence> valuesIterator​(java.lang.CharSequence name)
      Returns all values for the header with the specified name.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach
    • Field Detail

    • Method Detail

      • get

        @Nullable
        public java.lang.CharSequence get​(java.lang.CharSequence name)
        Description copied from interface: HttpHeaders
        Returns the value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
        Specified by:
        get in interface HttpHeaders
        Parameters:
        name - the name of the header to retrieve.
        Returns:
        the first header value if the header is found. null if there's no such header.
      • get

        public java.lang.CharSequence get​(java.lang.CharSequence name,
                                          java.lang.CharSequence defaultValue)
        Description copied from interface: HttpHeaders
        Returns the value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.
        Specified by:
        get in interface HttpHeaders
        Parameters:
        name - the name of the header to retrieve.
        defaultValue - the default value.
        Returns:
        the first header value or defaultValue if there is no such header.
      • getAndRemove

        @Nullable
        public java.lang.CharSequence getAndRemove​(java.lang.CharSequence name)
        Description copied from interface: HttpHeaders
        Returns the value of a header with the specified name and removes it from this object. If there is more than one value for the specified name, the first value in insertion order is returned.
        Specified by:
        getAndRemove in interface HttpHeaders
        Parameters:
        name - the name of the header to retrieve.
        Returns:
        the first header value or null if there is no such header.
      • contains

        public boolean contains​(java.lang.CharSequence name,
                                java.lang.CharSequence value)
        Description copied from interface: HttpHeaders
        Returns true if a header with the name and value exists, false otherwise.
        Specified by:
        contains in interface HttpHeaders
        Parameters:
        name - the header name.
        value - the header value of the header to find.
        Returns:
        true if a name, value pair exists.
      • containsIgnoreCase

        public boolean containsIgnoreCase​(java.lang.CharSequence name,
                                          java.lang.CharSequence value)
        Description copied from interface: HttpHeaders
        Returns true if a header with the name and value exists, false otherwise.

        Case insensitive compare is done on the value.

        Specified by:
        containsIgnoreCase in interface HttpHeaders
        Parameters:
        name - the name of the header to find.
        value - the value of the header to find.
        Returns:
        true if found.
      • size

        public int size()
        Description copied from interface: HttpHeaders
        Returns the number of headers in this object.
        Specified by:
        size in interface HttpHeaders
        Returns:
        the number of headers in this object.
      • names

        public java.util.Set<? extends java.lang.CharSequence> names()
        Description copied from interface: HttpHeaders
        Returns a Set of all header names in this object. The returned Set cannot be modified.
        Specified by:
        names in interface HttpHeaders
        Returns:
        a Set of all header names in this object. The returned Set cannot be modified.
      • add

        public HttpHeaders add​(java.lang.CharSequence name,
                               java.lang.CharSequence value)
        Description copied from interface: HttpHeaders
        Adds a new header with the specified name and value.
        Specified by:
        add in interface HttpHeaders
        Parameters:
        name - the name of the header.
        value - the value of the header.
        Returns:
        this.
      • add

        public HttpHeaders add​(java.lang.CharSequence name,
                               java.lang.Iterable<? extends java.lang.CharSequence> values)
        Description copied from interface: HttpHeaders
        Adds new headers with the specified name and values. This method is semantically equivalent to:
         for (T value : values) {
             headers.add(name, value);
         }
         
        Specified by:
        add in interface HttpHeaders
        Parameters:
        name - the name of the header.
        values - the values of the header.
        Returns:
        this.
      • add

        public HttpHeaders add​(java.lang.CharSequence name,
                               java.lang.CharSequence... values)
        Description copied from interface: HttpHeaders
        Adds new headers with the specified name and values. This method is semantically equivalent to:
         for (T value : values) {
             headers.add(name, value);
         }
         
        Specified by:
        add in interface HttpHeaders
        Parameters:
        name - the name of the header.
        values - the values of the header.
        Returns:
        this.
      • add

        public HttpHeaders add​(HttpHeaders headers)
        Description copied from interface: HttpHeaders
        Adds all header names and values of headers to this object.
        Specified by:
        add in interface HttpHeaders
        Parameters:
        headers - the headers to add.
        Returns:
        this.
      • set

        public HttpHeaders set​(java.lang.CharSequence name,
                               java.lang.CharSequence value)
        Description copied from interface: HttpHeaders
        Sets a header with the specified name and value. Any existing headers with the same name are overwritten.
        Specified by:
        set in interface HttpHeaders
        Parameters:
        name - the name of the header.
        value - the value of the header.
        Returns:
        this.
      • set

        public HttpHeaders set​(java.lang.CharSequence name,
                               java.lang.Iterable<? extends java.lang.CharSequence> values)
        Description copied from interface: HttpHeaders
        Sets a new header with the specified name and values. This method is equivalent to:
         headers.remove(name);
         for (T value : values) {
             headers.add(name, value);
         }
         
        Specified by:
        set in interface HttpHeaders
        Parameters:
        name - the name of the header.
        values - the values of the header.
        Returns:
        this.
      • set

        public HttpHeaders set​(java.lang.CharSequence name,
                               java.lang.CharSequence... values)
        Description copied from interface: HttpHeaders
        Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:
         headers.remove(name);
         for (T value : values) {
             headers.add(name, value);
         }
         
        Specified by:
        set in interface HttpHeaders
        Parameters:
        name - the name of the header.
        values - the values of the header.
        Returns:
        this.
      • set

        public HttpHeaders set​(HttpHeaders headers)
        Description copied from interface: HttpHeaders
        Clears the current header entries and copies all header entries of the specified headers object.
        Specified by:
        set in interface HttpHeaders
        Parameters:
        headers - the headers object which contains new values.
        Returns:
        this.
      • replace

        public HttpHeaders replace​(HttpHeaders headers)
        Description copied from interface: HttpHeaders
        Removes all header names contained in headers from this object, and then adds all headers contained in headers.
        Specified by:
        replace in interface HttpHeaders
        Parameters:
        headers - the headers used to remove names and then add new entries.
        Returns:
        this.
      • remove

        public boolean remove​(java.lang.CharSequence name)
        Description copied from interface: HttpHeaders
        Removes all headers with the specified name.
        Specified by:
        remove in interface HttpHeaders
        Parameters:
        name - the name of the header.
        Returns:
        true if at least one entry has been removed.
      • remove

        public boolean remove​(java.lang.CharSequence name,
                              java.lang.CharSequence value)
        Description copied from interface: HttpHeaders
        Removes specific value(s) from the specified header name. If the header has more than one identical values, all of them will be removed.
        Specified by:
        remove in interface HttpHeaders
        Parameters:
        name - the name of the header.
        value - the value of the header to remove.
        Returns:
        true if at least one value has been removed.
      • removeIgnoreCase

        public boolean removeIgnoreCase​(java.lang.CharSequence name,
                                        java.lang.CharSequence value)
        Description copied from interface: HttpHeaders
        Removes specific value(s) from the specified header name. If the header has more than one identical values, all of them will be removed.

        Case insensitive compare is done on the value.

        Specified by:
        removeIgnoreCase in interface HttpHeaders
        Parameters:
        name - the name of the header.
        value - the value of the header to remove.
        Returns:
        true if at least one value has been removed.
      • iterator

        public java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>> iterator()
        Specified by:
        iterator in interface HttpHeaders
        Specified by:
        iterator in interface java.lang.Iterable<java.util.Map.Entry<java.lang.CharSequence,​java.lang.CharSequence>>
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Description copied from interface: HttpHeaders
        Returns a String representation of this HttpHeaders. To avoid accidentally logging sensitive information, implementations should be cautious about logging header content and consider using HttpHeaders.toString(BiFunction).
        Specified by:
        toString in interface HttpHeaders
        Overrides:
        toString in class java.lang.Object
        Returns:
        a simple String representation of this HttpHeaders.
      • toString

        public java.lang.String toString​(java.util.function.BiFunction<? super java.lang.CharSequence,​? super java.lang.CharSequence,​java.lang.CharSequence> filter)
        Description copied from interface: HttpHeaders
        Builds a string which represents all the content in this HttpHeaders in which sensitive headers can be filtered via filter.
        Specified by:
        toString in interface HttpHeaders
        Parameters:
        filter - a function that accepts the header name and value and returns the filtered value.
        Returns:
        string representation of this HttpHeaders.
      • removeCookies

        public boolean removeCookies​(java.lang.CharSequence name)
        Description copied from interface: HttpHeaders
        Removes all cookie identified by name.
        Specified by:
        removeCookies in interface HttpHeaders
        Parameters:
        name - the cookie-name of the HttpSetCookies to remove.
        Returns:
        true if at least one entry has been removed.
      • removeSetCookies

        public boolean removeSetCookies​(java.lang.CharSequence name)
        Description copied from interface: HttpHeaders
        Removes all set-cookie identified by name.
        Specified by:
        removeSetCookies in interface HttpHeaders
        Parameters:
        name - the cookie-name of the HttpSetCookies to remove.
        Returns:
        true if at least one entry has been removed.
      • removeSetCookies

        public boolean removeSetCookies​(java.lang.CharSequence name,
                                        java.lang.CharSequence domain,
                                        java.lang.CharSequence path)
        Description copied from interface: HttpHeaders
        Removes all set-cookie identified by name.
        Specified by:
        removeSetCookies in interface HttpHeaders
        Parameters:
        name - the cookie-name of the HttpSetCookies to remove.
        domain - the domain-value of the HttpSetCookies to remove. This value may be matched according to the Domain Matching algorithm.
        path - the path-av of the HttpSetCookies to remove. This value may be matched according to the Path Matching algorithm.
        Returns:
        true if at least one entry has been removed.