Class HttpRequest


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

      Fields 
      Modifier and Type Field Description
      protected java.lang.String m_identd
      Remote identification of the user
      protected HttpRequest.Method m_method
      The method used for the request (GET, POST)
      protected java.util.Map<java.lang.String,​java.lang.String> m_parameters
      The parameters of this method
      protected java.lang.String m_path
      The path of the request
      protected int m_responseCode
      The response code sent
      protected int m_size
      The size of the response sent
      protected java.lang.String m_sourceIp
      The source IP address
      protected long m_unixTime
      The time of the request: a Unix timestamp in seconds
      protected java.lang.String m_userId
      User ID
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpRequest​(java.lang.String source_ip, java.lang.String identd, java.lang.String userid, long unix_time, HttpRequest.Method method, java.lang.String path, java.util.Map<java.lang.String,​java.lang.String> parameters, int response_code, int size)
      Creates a new HTTP request event
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static long dateToTimestamp​(java.util.Calendar calendar, java.lang.String time_string)
      Converts a date in the format YYYY-MM-DD HH:MM:SS into a Unix timestamp.
      java.lang.String get​(java.lang.String parameter_name)
      Gets the value of a parameter in the HTTP request
      HttpRequest.Method getMethod()
      Gets the method of this HTTP request
      java.util.Map<java.lang.String,​java.lang.String> getParameters()
      Returns the parameters associated with this HTTP request
      java.lang.String getPath()
      Gets the path of this HTTP request
      int getResponseCode()
      Gets the response code of this HTTP request
      int getResponseSize()
      Gets the size of the response to this HTTP request
      java.lang.String getSourceIp()
      Gets the source IP address of this HTTP request
      long getTimestamp()
      Gets the timestamp of this request
      java.lang.String getUser()
      Gets the user associated to this HTTP request
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • m_sourceIp

        protected final java.lang.String m_sourceIp
        The source IP address
      • m_identd

        protected final java.lang.String m_identd
        Remote identification of the user
      • m_userId

        protected final java.lang.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 java.lang.String m_path
        The path of the request
      • m_parameters

        protected final java.util.Map<java.lang.String,​java.lang.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 Detail

      • HttpRequest

        public HttpRequest​(java.lang.String source_ip,
                           java.lang.String identd,
                           java.lang.String userid,
                           long unix_time,
                           HttpRequest.Method method,
                           java.lang.String path,
                           java.util.Map<java.lang.String,​java.lang.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 Detail

      • getSourceIp

        public java.lang.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 java.lang.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 java.lang.String getPath()
        Gets the path of this HTTP request
        Returns:
        The path
      • getParameters

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

        public java.lang.String get​(java.lang.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​(java.util.Calendar calendar,
                                           java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object