Beispiel #1
0
  /**
   * Initializes an instance of the CacheEntry class using the specified HTTP request and response
   * information, cache diagnosis value, and number of bytes in the cache.
   *
   * @param request An HttpRequestResponseInfo object containing the request. This parameter can be
   *     null if the response is not matched to the request.
   * @param response An HttpRequestResponseInfo object containing the response. This parameter
   *     cannot be null
   * @param diagnosis A CacheEntry.Diagnosis enumeration value that identifies the diagnosis (or
   *     category) of this cache entry.
   * @param bytesInCache The number of bytes in the cache. This parameter is used for responses with
   *     data partially in the cache.
   * @param sessionFirstPacket The first packet of session.
   */
  public CacheEntry(
      HttpRequestResponseInfo request,
      HttpRequestResponseInfo response,
      Diagnosis diagnosis,
      long bytesInCache,
      PacketInfo sessionFirstPacket) {
    if (request != null) {
      this.request = request;
      this.rawBytes += request.getRawSize();
    }

    if (request != null) {
      this.timeStamp = 0.0; // request.getTimeStamp();
      this.httpObjectName = request.getObjName();
      this.hostName = request.getHostName();
      httpRequestResponse = request.getAssocReqResp();
    } else {
      this.httpObjectName = "";
      this.hostName = "";
    }

    // Response cannot be null
    this.response = response;
    this.rawBytes += response.getRawSize();

    this.contentLength = getResponse().getContentLength();
    this.diagnosis = diagnosis;
    this.bytesInCache = Math.min(bytesInCache, rawBytes);
    this.bytesNotInCache = Math.max(0, rawBytes - bytesInCache);
    this.sessionFirstPacket = sessionFirstPacket;
  }