Utility method to create a single header instance with the given
information. If elements already exist, this will delete secondary
ones and overlay the value on the first element.

@param key
@param value
@param offset
@param length
2171
private void createSingleHeader(HeaderKeys key, byte[] value, int offset, int length) {
        HeaderElement elem = findHeader(key);
        if (null != elem) {
            // delete all secondary instances first
            if (null != elem.nextInstance) {
                HeaderElement temp = elem.nextInstance;
                while (null != temp) {
                    temp.remove();
                    temp = temp.nextInstance;
                }
            }
            if (HeaderStorage.NOTSET != this.headerChangeLimit) {
                // parse buffer reuse is enabled, see if we can use existing obj
                if (length <= elem.getValueLength()) {
                    this.headerChangeCount++;
                    elem.setByteArrayValue(value, offset, length);
                } else {
                    elem.remove();
                    elem = null;
                }
            } else {
                // parse buffer reuse is disabled
                elem.setByteArrayValue(value, offset, length);
            }
        }
        if (null == elem) {
            // either it didn't exist or we chose not to re-use the object
            elem = getElement(key);
            elem.setByteArrayValue(value, offset, length);
            addHeader(elem, FILTER_NO);
        } else if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Replacing header " + key.getName() + " [" + elem.getDebugValue() + "]");
        }
    }
455983
public V put (int key, V value)
    {
        // check to see if we've passed our load factor, if so: resize
        ensureCapacity(_size + 1);

        int index = keyToIndex(key);
        Record<V> rec = _buckets[index];

        // either we start a new chain
        if (rec == null) {
            _buckets[index] = new Record<V>(key, value);
            _size++; // we're bigger
            return null;
        }

        // or we replace an element in an existing chain
        Record<V> prev = rec;
        for (; rec != null; rec = rec.next) {
            if (rec.key == key) {
                V ovalue = rec.value;
                rec.value = value; // we're not bigger
                return ovalue;
            }
            prev = rec;
        }

        // or we append it to this chain
        prev.next = new Record<V>(key, value);
        _size++; // we're bigger
        return null;
    }
687551
@Override
  public CharSegment getHeaderBuffer(String key)
  {
    int i = matchNextHeader(0, key);

    if (i >= 0) {
      return _headerValues[i];
    }
    else {
      return null;
    }
  }
736216
@Override
    public V put(String key, V value) {
        // Keys can not be null
        if (key == null) {
            throw new NullPointerException("Key can not be null");
        }

        // Empty keys are stored in the root
        if (key.equals("")) {
            PatriciaNode<V> node = new PatriciaNode<>(key, value, -1);
            node.setValue(value);
            root.setRight(node);
            entries++;
            return value;
        }

        // Find nearest node
        PatriciaNode<V> nearest = findNearestNode(key);

        // Key already exist, replace value and return
        if (key.equals(nearest.getKey())) {
            nearest.setValue(value);
            return value;
        }

        // Find differing bit and create new node to insert
        int bit = findFirstDifferingBit(key, nearest.getKey());
        PatriciaNode<V> node = new PatriciaNode<>(key, value, bit);

        // Insert new node
        insertNode(node);

        entries++;

        return value;
    }
210364
public Request header(String key, String value) {
        this.headers.put(key, value);
        return this;
    }
502327
public static Action header(final String key, final String value) {
        return new Action(input -> {
            input.setHeader(key, value);
            return input;
        });
    }
1288352
public Map<String, String> addRequestHeader(String key, String value) {
    this.requestHeaders.put(key, value);
    return getRequestHeaders();
  }
687360
function(key, value) {
          const key2 = key.toLowerCase().replace(/[^a-z0-9]/ig, '');
          res.serverassist.headers[key]    = value;
          res.serverassist.headers2[key2]  = value;
        }
365975
public synchronized final V put(K key, V value) {
        if (key == null) {
            throw new NullPointerException("key == null");
        } else if (value == null) {
            throw new NullPointerException("value == null");
        }

        V previous = map.put(key, value);
        trimToSize(maxSize);
        return previous;
    }
562996
public void mergeHeader(InputStream is) throws java.io.IOException {
        if (is == null)
            return;
        char s[] = new char[10];
        int firstc = is.read();
        while (firstc != '\n' && firstc != '\r' && firstc >= 0) {
            int len = 0;
            int keyend = -1;
            int c;
            boolean inKey = firstc > ' ';
            s[len++] = (char) firstc;
    parseloop:{
                while ((c = is.read()) >= 0) {
                    switch (c) {
                      case ':':
                        if (inKey && len > 0)
                            keyend = len;
                        inKey = false;
                        break;
                      case '\t':
                        c = ' ';
                      case ' ':
                        inKey = false;
                        break;
                      case '\r':
                      case '\n':
                        firstc = is.read();
                        if (c == '\r' && firstc == '\n') {
                            firstc = is.read();
                            if (firstc == '\r')
                                firstc = is.read();
                        }
                        if (firstc == '\n' || firstc == '\r' || firstc > ' ')
                            break parseloop;
                        /* continuation */
                        c = ' ';
                        break;
                    }
                    if (len >= s.length) {
                        char ns[] = new char[s.length * 2];
                        System.arraycopy(s, 0, ns, 0, len);
                        s = ns;
                    }
                    s[len++] = (char) c;
                }
                firstc = -1;
            }
            while (len > 0 && s[len - 1] <= ' ')
                len--;
            String k;
            if (keyend <= 0) {
                k = null;
                keyend = 0;
            } else {
                k = String.copyValueOf(s, 0, keyend);
                if (keyend < len && s[keyend] == ':')
                    keyend++;
                while (keyend < len && s[keyend] <= ' ')
                    keyend++;
            }
            String v;
            if (keyend >= len)
                v = new String();
            else
                v = String.copyValueOf(s, keyend, len - keyend);
            add(k, v);
        }
    }
1337116
@Override
  public void getHeaderBuffers(String key, ArrayList<CharSegment> values)
  {
    int i = -1;
    
    while ((i = matchNextHeader(i + 1, key)) >= 0) {
      values.add(_headerValues[i]);
    }
  }
167496
protected void insertNewKeyValueAt(int i, short key, Container value) {
    extendArray(1);
    System.arraycopy(keys, i, keys, i + 1, size - i);
    keys[i] = key;
    System.arraycopy(values, i, values, i + 1, size - i);
    values[i] = value;
    size++;
  }
292767
protected void setHeaderOutImpl(String key, String value)
  {
    int i = 0;
    boolean hasHeader = false;
    
    ArrayList<String> keys = _headerKeysOut;
    ArrayList<String> values = _headerValuesOut;

    for (i = keys.size() - 1; i >= 0; i--) {
      String oldKey = keys.get(i);

      if (oldKey.equalsIgnoreCase(key)) {
        if (hasHeader) {
          keys.remove(i);
          values.remove(i);
        }
        else {
          hasHeader = true;

          values.set(i, value);
        }
      }
    }

    if (! hasHeader) {
      keys.add(key);
      values.add(value);
    }
  }
1114121
public S setParameter(String key, String value) {
        if (parameters == null) {
            parameters = new ConcurrentHashMap<String, String>();
        }
        if (value == null) {
            parameters.remove(key);
        } else {
            parameters.put(key, value);
        }
        return castThis();
    }
371566
function (key, value) {
            if (!base.isString(key)) {
                var l = this.__heap.push(this.__makeNode(key, value));
                this.__upHeap(l - 1);
            } else {
                throw new TypeError("Invalid key");
            }
        }
335191
public void addHeader(String key, String value) {
        if (key.equals("As-User")) {
            for (int i = 0; i < this.headers.size(); i++) {
                if (this.headers.get(i).getKey().equals("As-User")) {
                    this.headers.remove(i);
                }
            }
        }
        if (key.equals("X-Box-UA")) {
            throw new IllegalArgumentException("Altering the X-Box-UA header is not permitted");
        }
        this.headers.add(new RequestHeader(key, value));
    }
322344
private void overlayValue(HeaderElement elem) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Overlaying existing header: " + elem.getName());
        }
        int next_index = this.lastCRLFBufferIndex;
        int next_pos = this.lastCRLFPosition;
        if (null != elem.nextSequence && !elem.nextSequence.wasAdded()) {
            next_index = elem.nextSequence.getLastCRLFBufferIndex();
            next_pos = elem.nextSequence.getLastCRLFPosition();
        }
        WsByteBuffer buffer = this.parseBuffers[elem.getLastCRLFBufferIndex()];
        buffer.position(elem.getLastCRLFPosition() + (elem.isLastCRLFaCR() ? 2 : 1));
        if (next_index == elem.getLastCRLFBufferIndex()) {
            // all in one buffer
            buffer.put(elem.getKey().getMarshalledByteArray(foundCompactHeader()));
            buffer.put(elem.asRawBytes(), elem.getOffset(), elem.getValueLength());
        } else {
            // header straddles buffers
            int index = elem.getLastCRLFBufferIndex();
            index = overlayBytes(elem.getKey().getMarshalledByteArray(foundCompactHeader()), 0, -1, index);
            index = overlayBytes(elem.asRawBytes(), elem.getOffset(), elem.getValueLength(), index);
            buffer = this.parseBuffers[index];
        }
        // pad trailing whitespace if we need it
        int start = buffer.position();
        if (start < next_pos) {
            scribbleWhiteSpace(buffer, start, next_pos);
        }
    }