Package ca.uqac.lif.cep.apache
Class HttpRequest
- java.lang.Object
-
- ca.uqac.lif.cep.apache.HttpRequest
-
public class HttpRequest extends java.lang.Object
Representation of an HTTP request, as logged by an Apache server- Author:
- Sylvain Hallé
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpRequest.GetParameter
Function to get the path of an HTTP requeststatic class
HttpRequest.GetPath
Function to get the path of an HTTP requeststatic class
HttpRequest.GetTimestamp
Function to get the timestamp of an HTTP requeststatic class
HttpRequest.Method
The HTTP method used in the requeststatic class
HttpRequest.RequestIsAfter
Function to compare the request's time with another time
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
m_identd
Remote identification of the userprotected 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 methodprotected java.lang.String
m_path
The path of the requestprotected int
m_responseCode
The response code sentprotected int
m_size
The size of the response sentprotected java.lang.String
m_sourceIp
The source IP addressprotected long
m_unixTime
The time of the request: a Unix timestamp in secondsprotected 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 requestHttpRequest.Method
getMethod()
Gets the method of this HTTP requestjava.util.Map<java.lang.String,java.lang.String>
getParameters()
Returns the parameters associated with this HTTP requestjava.lang.String
getPath()
Gets the path of this HTTP requestint
getResponseCode()
Gets the response code of this HTTP requestint
getResponseSize()
Gets the size of the response to this HTTP requestjava.lang.String
getSourceIp()
Gets the source IP address of this HTTP requestlong
getTimestamp()
Gets the timestamp of this requestjava.lang.String
getUser()
Gets the user associated to this HTTP requestjava.lang.String
toString()
-
-
-
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 addressidentd
- The identifieruserid
- The user IDunix_time
- A Unix timestampmethod
- The method (i.e. GET, POST, etc.)path
- The URL's pathparameters
- The URL's parameters, if anyresponse_code
- The response code of this requestsize
- 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 objecttime_string
- The time string- Returns:
- The timestamp
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-