Class HttpRequest

java.lang.Object
ca.uqac.lif.cep.apache.HttpRequest

public class HttpRequest extends Object
Representation of an HTTP request, as logged by an Apache server
Author:
Sylvain Hallé
  • Field Details

    • m_sourceIp

      protected final String m_sourceIp
      The source IP address
    • m_identd

      protected final String m_identd
      Remote identification of the user
    • m_userId

      protected final String m_userId
      User ID
    • m_unixTime

      protected final long m_unixTime
      The time of the request: a Unix timestamp in seconds
    • m_method

      protected final HttpRequest.Method m_method
      The method used for the request (GET, POST)
    • m_path

      protected final String m_path
      The path of the request
    • m_parameters

      protected final Map<String,String> m_parameters
      The parameters of this method
    • m_responseCode

      protected final int m_responseCode
      The response code sent
    • m_size

      protected final int m_size
      The size of the response sent
  • Constructor Details

    • HttpRequest

      public HttpRequest(String source_ip, String identd, String userid, long unix_time, HttpRequest.Method method, String path, Map<String,String> parameters, int response_code, int size)
      Creates a new HTTP request event
      Parameters:
      source_ip - The source IP address
      identd - The identifier
      userid - The user ID
      unix_time - A Unix timestamp
      method - The method (i.e. GET, POST, etc.)
      path - The URL's path
      parameters - The URL's parameters, if any
      response_code - The response code of this request
      size - The size of the request
  • Method Details

    • getSourceIp

      public String getSourceIp()
      Gets the source IP address of this HTTP request
      Returns:
      The address
    • getTimestamp

      public long getTimestamp()
      Gets the timestamp of this request
      Returns:
      The Unix timestamp
    • getResponseSize

      public int getResponseSize()
      Gets the size of the response to this HTTP request
      Returns:
      The size of the response
    • getResponseCode

      public int getResponseCode()
      Gets the response code of this HTTP request
      Returns:
      The code
    • getUser

      public String getUser()
      Gets the user associated to this HTTP request
      Returns:
      The user
    • getMethod

      public HttpRequest.Method getMethod()
      Gets the method of this HTTP request
      Returns:
      The method
    • getPath

      public String getPath()
      Gets the path of this HTTP request
      Returns:
      The path
    • getParameters

      public Map<String,String> getParameters()
      Returns the parameters associated with this HTTP request
      Returns:
      The parameters
    • get

      public String get(String parameter_name)
      Gets the value of a parameter in the HTTP request
      Parameters:
      parameter_name - The name of the parameter
      Returns:
      The value if the parameter exists, null otherwise
    • dateToTimestamp

      public static long dateToTimestamp(Calendar calendar, String time_string)
      Converts a date in the format YYYY-MM-DD HH:MM:SS into a Unix timestamp. The time is optional, and if specified, the seconds are optional.
      Parameters:
      calendar - An instance of calendar object
      time_string - The time string
      Returns:
      The timestamp
    • toString

      public String toString()
      Overrides:
      toString in class Object