Class Headers


  • public class Headers
    extends Object
    Container class for HTTP headers.
    • Constructor Detail

      • Headers

        public Headers()
    • Method Detail

      • getHeader

        public String getHeader​(String name)
        Return the first header matching a given name.
        Parameters:
        name - name
        Returns:
        value of header or null
      • getHeaders

        public String[] getHeaders​(String name)
        Return all headers matching a given name.
        Parameters:
        name - name
        Returns:
        matching values or null
      • getDateHeader

        public long getDateHeader​(String name)
        Return the first header matching a given name.
        Parameters:
        name - name
        Returns:
        value of date header or -1
      • getIntHeader

        public int getIntHeader​(String name)
        Return the first header matching a given name.
        Parameters:
        name - name
        Returns:
        value of date header or 0
      • setHeader

        public void setHeader​(String name,
                              String value)
        Set a header. This will replace the first existing entry or add a new one.
        Parameters:
        name - name
        value - value, if null remove an existing header
      • setHeader

        public void setHeader​(String name,
                              long value)
        Set a header. This will replace the first existing entry or add a new one.
        Parameters:
        name - name
        value - value
      • setHeader

        public void setHeader​(String name,
                              int value)
        Set a header. This will replace the first existing entry or add a new one.
        Parameters:
        name - name
        value - value
      • addHeader

        public void addHeader​(String name,
                              String value)
        Add a header.
        Parameters:
        name - name
        value - value
      • addHeader

        public void addHeader​(String name,
                              long value)
        Add a header.
        Parameters:
        name - name
        value - value
      • addHeader

        public void addHeader​(String name,
                              int value)
        Add a header.
        Parameters:
        name - name
        value - value
      • getEntries

        public Headers.Entry[] getEntries()
        Return all entries.
        Returns:
        entries
      • save

        public void save​(OutputStream out)
                  throws IOException
        Store headers to an output stream.
        Parameters:
        out - output stream
        Throws:
        IOException - if an I/O error occurs
      • load

        public void load​(InputStream in)
                  throws IOException
        Load stored headers from an input stream.
        Parameters:
        in - input stream
        Throws:
        IOException - if an I/O error occurs