// A Request is a (usually HTTP) request from a client to a proxy and
// the results of that request.  ie. Was the URL fetched from 
// the server or supplied from cache?  What was the HTTP result code?

#if !defined(_Request_h)
#define _Request_h

#include <stdio.h>

const int INPUT_LINE_SIZE = 5000;

class SquidRequest
{
public:
  enum ProxyResultCode {
    unknownProxyResult, // 0
    hit,         // 1
    miss,        // 2
    refreshHit,  // 3 - Request resulted in IMS request to server, but URL
                 //     was not modified.  HTTP code should be 304.
    refreshMiss, // 4 - Request resulted in IMS request to server, and
                 //     modified URL was retrieved.
    imsHit,      // 5 - Client's IMS request was in cache, fresh
    imsMiss,     // 6 - Client made IMS request for stale object
    clientRefresh, // 7 - Client made a no-cache request
    refFailHit,  // 8 - Stale object in cache could not be refreshed
  };

  static char* ProxyResultText[] = {
    "Unknown",
    "Hit",
    "Miss",
    "RefreshHit",
    "RefreshMiss"
  };

  enum HttpResultCode {
    unknownHttpResult = 0,
    ok                = 200, // c
    noContent         = 204, // E
    movedPermenently  = 301, // C
    movedTemporarily  = 302, // t
    notModified       = 304, // -
    badRequest        = 400, // E
    unauthorized      = 401, // -
    forbidden         = 403, // E
    notFound          = 404, // E
    internalServerError = 500, // E
    // Notes:
    // * HTTP 1.1
    // c Cached unless a query response without expiry information
    // C Cached
    // E Negatively cached if no expiry headers.
    // t Cached only if expiry information
    // - Not cached
  };


  // Time request completed in s since 1970
  long endTime;
  
  // Indentifier of client.
  long client;

  // Real time used to process request, in s.
  long processingTime;

  // Result code from proxy
  ProxyResultCode proxyResult;

  // Result code from HTTP
  HttpResultCode httpResult;

  // Number of bytes sent to client, including headers.
  int size;

  // Request URL
  char url[1000];

  // Copy of input line
  char line[INPUT_LINE_SIZE];

  // input line size
  int lineSize;

  // Just initializes the fields.
  SquidRequest();
};
#endif
