Exemplo n.º 1
0
 /* -------------------------------------------------------------- */
 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);
 }
Exemplo n.º 2
0
  /** 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;
  }
Exemplo n.º 3
0
  /**
   * 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;
  }
Exemplo n.º 4
0
    /* ------------------------------------------------------------ */
    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);
    }
Exemplo n.º 5
0
 /**
  * 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);
 }
Exemplo n.º 6
0
 /**
  * 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);
 }
Exemplo n.º 7
0
 /**
  * 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);
 }
Exemplo n.º 8
0
 /* ------------------------------------------------------------ */
 public long getLongValue() {
   return BufferUtil.toLong(_value);
 }
Exemplo n.º 9
0
 /* ------------------------------------------------------------ */
 public String getValue() {
   return BufferUtil.to8859_1_String(_value);
 }
Exemplo n.º 10
0
 /* ------------------------------------------------------------ */
 public String getName() {
   return BufferUtil.to8859_1_String(_name);
 }