Package ca.uqac.lif.cep.apache
Class HttpRequest
- java.lang.Object
-
- ca.uqac.lif.cep.apache.HttpRequest
-
public class HttpRequest extends java.lang.ObjectRepresentation of an HTTP request, as logged by an Apache server- Author:
- Sylvain Hallé
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpRequest.GetParameterFunction to get the path of an HTTP requeststatic classHttpRequest.GetPathFunction to get the path of an HTTP requeststatic classHttpRequest.GetTimestampFunction to get the timestamp of an HTTP requeststatic classHttpRequest.MethodThe HTTP method used in the requeststatic classHttpRequest.RequestIsAfterFunction to compare the request's time with another time
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Stringm_identdRemote identification of the userprotected HttpRequest.Methodm_methodThe method used for the request (GET, POST)protected java.util.Map<java.lang.String,java.lang.String>m_parametersThe parameters of this methodprotected java.lang.Stringm_pathThe path of the requestprotected intm_responseCodeThe response code sentprotected intm_sizeThe size of the response sentprotected java.lang.Stringm_sourceIpThe source IP addressprotected longm_unixTimeThe time of the request: a Unix timestamp in secondsprotected java.lang.Stringm_userIdUser 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 longdateToTimestamp(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.Stringget(java.lang.String parameter_name)Gets the value of a parameter in the HTTP requestHttpRequest.MethodgetMethod()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.StringgetPath()Gets the path of this HTTP requestintgetResponseCode()Gets the response code of this HTTP requestintgetResponseSize()Gets the size of the response to this HTTP requestjava.lang.StringgetSourceIp()Gets the source IP address of this HTTP requestlonggetTimestamp()Gets the timestamp of this requestjava.lang.StringgetUser()Gets the user associated to this HTTP requestjava.lang.StringtoString()
-
-
-
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,
nullotherwise
-
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:
toStringin classjava.lang.Object
-
-