Class Headers


  • public class Headers
    extends java.lang.Object
    Container class for HTTP headers.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Headers.Entry
      A header entry.
    • Constructor Summary

      Constructors 
      Constructor Description
      Headers()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHeader​(java.lang.String name, int value)
      Add a header.
      void addHeader​(java.lang.String name, long value)
      Add a header.
      void addHeader​(java.lang.String name, java.lang.String value)
      Add a header.
      long getDateHeader​(java.lang.String name)
      Return the first header matching a given name.
      Headers.Entry[] getEntries()
      Return all entries.
      java.lang.String getHeader​(java.lang.String name)
      Return the first header matching a given name.
      java.lang.String[] getHeaders​(java.lang.String name)
      Return all headers matching a given name.
      int getIntHeader​(java.lang.String name)
      Return the first header matching a given name.
      void load​(java.io.InputStream in)
      Load stored headers from an input stream.
      void save​(java.io.OutputStream out)
      Store headers to an output stream.
      void setHeader​(java.lang.String name, int value)
      Set a header.
      void setHeader​(java.lang.String name, long value)
      Set a header.
      void setHeader​(java.lang.String name, java.lang.String value)
      Set a header.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Headers

        public Headers()
    • Method Detail

      • getHeader

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

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

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

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

        public void setHeader​(java.lang.String name,
                              java.lang.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​(java.lang.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​(java.lang.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​(java.lang.String name,
                              java.lang.String value)
        Add a header.
        Parameters:
        name - name
        value - value
      • addHeader

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

        public void addHeader​(java.lang.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​(java.io.OutputStream out)
                  throws java.io.IOException
        Store headers to an output stream.
        Parameters:
        out - output stream
        Throws:
        java.io.IOException - if an I/O error occurs
      • load

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object