/* -------------------------------------------------------------- */
 public void putTo(Buffer buffer) throws IOException {
   for (int i = 0; i < _fields.size(); i++) {
     Field field = _fields.get(i);
     if (field != null) field.putTo(buffer);
   }
   BufferUtil.putCRLF(buffer);
 }
  /** Get Collection of header names. */
  public Collection<String> getFieldNamesCollection() {
    final List<String> list = new ArrayList<String>(_fields.size());

    for (Field f : _fields) {
      if (f != null) list.add(BufferUtil.to8859_1_String(f._name));
    }
    return list;
  }
  /**
   * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case
   * of the field name is ignored.
   *
   * @param name the case-insensitive field name
   */
  public long getDateField(String name) {
    Field field = getField(name);
    if (field == null) return -1;

    String val = valueParameters(BufferUtil.to8859_1_String(field._value), null);
    if (val == null) return -1;

    final long date = __dateParser.get().parse(val);
    if (date == -1) throw new IllegalArgumentException("Cannot convert date: " + val);
    return date;
  }
    /* ------------------------------------------------------------ */
    public void putTo(Buffer buffer) throws IOException {
      int o = (_name instanceof CachedBuffer) ? ((CachedBuffer) _name).getOrdinal() : -1;
      if (o >= 0) buffer.put(_name);
      else {
        int s = _name.getIndex();
        int e = _name.putIndex();
        while (s < e) {
          byte b = _name.peek(s++);
          switch (b) {
            case '\r':
            case '\n':
            case ':':
              continue;
            default:
              buffer.put(b);
          }
        }
      }

      buffer.put((byte) ':');
      buffer.put((byte) ' ');

      o = (_value instanceof CachedBuffer) ? ((CachedBuffer) _value).getOrdinal() : -1;
      if (o >= 0) buffer.put(_value);
      else {
        int s = _value.getIndex();
        int e = _value.putIndex();
        while (s < e) {
          byte b = _value.peek(s++);
          switch (b) {
            case '\r':
            case '\n':
              continue;
            default:
              buffer.put(b);
          }
        }
      }

      BufferUtil.putCRLF(buffer);
    }
 /**
  * Sets the value of an long field.
  *
  * @param name the field name
  * @param value the field long value
  */
 public void addLongField(Buffer name, long value) {
   Buffer v = BufferUtil.toBuffer(value);
   add(name, v);
 }
 /**
  * Sets the value of an long field.
  *
  * @param name the field name
  * @param value the field long value
  */
 public void addLongField(String name, long value) {
   Buffer n = HttpHeaders.CACHE.lookup(name);
   Buffer v = BufferUtil.toBuffer(value);
   add(n, v);
 }
 /**
  * Sets the value of an long field.
  *
  * @param name the field name
  * @param value the field long value
  */
 public void putLongField(Buffer name, long value) {
   Buffer v = BufferUtil.toBuffer(value);
   put(name, v);
 }
 /* ------------------------------------------------------------ */
 public long getLongValue() {
   return BufferUtil.toLong(_value);
 }
 /* ------------------------------------------------------------ */
 public String getValue() {
   return BufferUtil.to8859_1_String(_value);
 }
 /* ------------------------------------------------------------ */
 public String getName() {
   return BufferUtil.to8859_1_String(_name);
 }