Package sun.net.www

Class MessageHeader


  • public class MessageHeader
    extends Object
    An RFC 844 or MIME message header. Includes methods for parsing headers from incoming streams, fetching values, setting values, and printing headers. Key values of null are legal: they indicate lines in the header that don't have a valid key, but do have a value (this isn't legal according to the standard, but lines like this are everywhere).
    • Method Detail

      • getHeaderNamesInList

        public String getHeaderNamesInList()
        Returns list of header names in a comma separated list
      • reset

        public void reset()
        Reset a message header (all key/values removed)
      • findValue

        @Nullable
        public String findValue​(@Nullable
                                String k)
        Find the value that corresponds to this key. It finds only the first occurrence of the key.
        Parameters:
        k - the key to find.
        Returns:
        null if not found.
      • findNextValue

        @Nullable
        public String findNextValue​(@Nullable
                                    String k,
                                    String v)
        Deprecated: Use multiValueIterator() instead. Find the next value that corresponds to this key. It finds the first value that follows v. To iterate over all the values of a key use:
                  for(String v=h.findValue(k); v!=null; v=h.findNextValue(k, v)) {
                      ...
                  }
         
      • filterNTLMResponses

        public boolean filterNTLMResponses​(String k)
        Removes bare Negotiate and Kerberos headers when an "NTLM ..." appears. All Performed on headers with key being k.
        Returns:
        true if there is a change
      • multiValueIterator

        public Iterator<String> multiValueIterator​(String k)
        return an Iterator that returns all values of a particular key in sequence
      • print

        public void print​(PrintStream p)
        Prints the key-value pairs represented by this header. Also prints the RFC required blank line at the end. Omits pairs with a null key.
      • add

        public void add​(String k,
                        String v)
        Adds a key value pair to the end of the header. Duplicates are allowed
      • prepend

        public void prepend​(String k,
                            @Nullable
                            String v)
        Prepends a key value pair to the beginning of the header. Duplicates are allowed
      • set

        public void set​(int i,
                        String k,
                        @Nullable
                        String v)
        Overwrite the previous key/val pair at location 'i' with the new k/v. If the index didn't exist before the key/val is simply tacked onto the end.
      • remove

        public void remove​(@Nullable
                           String k)
        Remove the key from the header. If there are multiple values under the same key, they are all removed. Nothing is done if the key doesn't exist. After a remove, the other pairs' order are not changed.
        Parameters:
        k - the key to remove
      • set

        public void set​(String k,
                        String v)
        Sets the value of a key. If the key already exists in the header, it's value will be changed. Otherwise a new key/value pair will be added to the end of the header.
      • setIfNotSet

        public void setIfNotSet​(String k,
                                String v)
        Set's the value of a key only if there is no key with that value already.
      • canonicalID

        public static String canonicalID​(@Nullable
                                         String id)
        Convert a message-id string to canonical form (strips off leading and trailing <>s)
      • toString

        public String toString()
        Description copied from class: Object
        Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

        The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

         getClass().getName() + '@' + Integer.toHexString(hashCode())
         
        Overrides:
        toString in class Object
        Returns:
        a string representation of the object.