Package tkuri.jxy.arch

Source Code of tkuri.jxy.arch.GeneralHeaderInfo

package tkuri.jxy.arch;

import java.util.HashSet;
import java.util.Set;

import tkuri.jxy.Const;
import tkuri.jxy.Util;
import tkuri.uty.Bs;
import tkuri.uty.Buf;

public class GeneralHeaderInfo {


  public Set<Bs> hopByHop = new HashSet<Bs>();
  public boolean connectionClose = false;
  public boolean hasMessageBody = false;
  public long contentLength = 0;
  public Bs multipartFinalBorder = null;
  public boolean chunked = false;
  public boolean multipart = false;


  /**
   * ctor
   * @param aH
   * @param aDefaultConnClose
   */
  public GeneralHeaderInfo(HeaderList aH, boolean aDefaultConnClose) {

    connectionClose = aDefaultConnClose;

    hopByHop.add(Const.S_PROXY_CONNECTION.toLower());
    hopByHop.add(Const.S_CONNECTION.toLower());
    hopByHop.add(Const.S_TE.toLower());
    hopByHop.add(Const.S_TRAILER.toLower());
    // hopByHop_.add(S_TRANSFER_ENCODING.toLower()); これはそのまま転送してやれ
    hopByHop.add(Const.S_UPGRADE.toLower());

    for (HeaderPair hp: aH) {

      if (hp.name.equalsIgnoreCase(Const.S_PROXY_CONNECTION)
          || hp.name.equalsIgnoreCase(Const.S_CONNECTION)) { // Connection

        for (Bs v: Util.splitTrim(hp.value, ',')) {
          hopByHop.add(v.toLower());

          if (v.equalsIgnoreCase(Const.S_CLOSE)) {
            connectionClose = true;
          } else if (v.equalsIgnoreCase(Const.S_KEEP_ALIVE)) {
            connectionClose = false;
          }
        }

      } else if (hp.name.equalsIgnoreCase(Const.S_CONTENT_TYPE)) { // Content-Type
        for (Bs params: Util.splitTrim(hp.value, ';')) {
          Bs[] kv = Util.parseKeyValue(params);
          if (kv[0].equalsIgnoreCase(Const.S_BOUNDARY)) {
            Buf border = new Buf();
            border.appendAll(
                Const.L_HYP2
                , kv[1]
                , Const.L_HYP2);
            multipartFinalBorder = border.toBs();
          }
        }

      } else if (hp.name.equalsIgnoreCase(Const.S_CONTENT_LENGTH)) { // Content-Length
        contentLength = hp.value.toLong();

      } else if (hp.name.equalsIgnoreCase(Const.S_TRANSFER_ENCODING)) {
        chunked = true; // FIXME
      }
    }
  }
}
TOP

Related Classes of tkuri.jxy.arch.GeneralHeaderInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.