code: 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);
      }
    }
docs: Sets a header, replacing an already-existing header.
  
  @param key the header key to set.
  @param value the header value to set.