Class HttpServer.HttpHeaderMap

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map
    Enclosing class:
    HttpServer

    static class HttpServer.HttpHeaderMap
    extends java.util.LinkedHashMap
    Map implementation suitable for storing HTTP headers. It should be populated using the addHeader(java.lang.String, java.lang.String), not HashMap.put(K, V), method. This implementation should be used when a header is being constructed from an uncontrolled source of (key,value) pairs. If you are adding headers yourself and know that you won't duplicate keys, then a normal Map implementation will do.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpHeaderMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addHeader​(java.lang.String key, java.lang.String value)
      Adds a header value to this map.
      • Methods inherited from class java.util.LinkedHashMap

        clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
      • Methods inherited from class java.util.HashMap

        clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
    • Constructor Detail

      • HttpHeaderMap

        HttpHeaderMap()
    • Method Detail

      • addHeader

        public void addHeader​(java.lang.String key,
                              java.lang.String value)
        Adds a header value to this map. This differs from put in two subtle ways. First, key matching is case-insensitive. Second, if a value for the given key already exists, the new value will be appended after a comma, rather than replacing the old entry. See RFC2616 section 4.2 for the HTTP rules.
        Parameters:
        key - header name
        value - header value