Class Access
- java.lang.Object
-
- org.apache.synapse.transport.http.access.Access
-
public class Access extends Object
The class to handle the HTTP Access Logs, patterns and the major functionality. Major Code segment borrowed from Apache Tomcat's org.apache.catalina.valves.AccessLogValve with thanks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Access.AcceptCharSetElement
write the Accept Character Set Element - %Sprotected static class
Access.AcceptElement
write the Accept Element - %Cprotected static class
Access.AcceptEncodingElement
write the Accept Encoding Element - %eprotected static class
Access.AcceptLanguageElement
write the Accept Language Element - %Lprotected static interface
Access.AccessLogElement
AccessLogElement writes the partial message into the buffer.protected static class
Access.ByteSentElement
write bytes sent, excluding HTTP headers - %b, %Bprotected static class
Access.ConnectionElement
write the Connection Element - %xprotected static class
Access.ContentEncodingElement
write the Content Encoding Element - %nprotected static class
Access.ContentTypeElement
write the Content Type Element - %Tprotected static class
Access.CookieElement
write a specific cookie - %{xxx}cprotected class
Access.DateAndTimeElement
write date and time, in Common Log Format - %tprotected static class
Access.HeaderElement
write incoming headers - %{xxx}iprotected static class
Access.HostElement
write remote host name - %hprotected static class
Access.HttpStatusCodeElement
write HTTP status code of the response - %sprotected static class
Access.KeepAliveElement
write the Keep Alive Element - %kprotected static class
Access.LocalAddrElement
write local IP address - %Aprotected static class
Access.LocalServerNameElement
write local server name - %vprotected static class
Access.LogicalUserNameElement
write remote logical username from identd (always returns '-') - %lprotected static class
Access.MethodElement
write request method (GET, POST, etc.) - %mprotected static class
Access.RefererElement
write the referer - %fprotected static class
Access.RequestAttributeElement
write an attribute in the ServletRequest - %{xxx}r %Rprotected static class
Access.RequestElement
write first line of the request (method and request URI) - %rprotected static class
Access.RequestURIElement
write requested URL path - %Uprotected static class
Access.ResponseHeaderElement
write a specific response header - %{xxx}oprotected static class
Access.ServerElement
write the Server Element - %Zprotected static class
Access.StringElement
write any stringprotected static class
Access.TransferEncodingElement
write the Transfer Encoding Element - %Eprotected static class
Access.UserAgentElement
write the user agent - %aprotected static class
Access.UserElement
write remote user that was authenticated (if any), else '-' - %uprotected static class
Access.VaryElement
write the Vary Element - %V
-
Field Summary
Fields Modifier and Type Field Description protected Access.AccessLogElement[]
logElements
Array of AccessLogElement, they will be used to make log message.protected String
pattern
-
Constructor Summary
Constructors Constructor Description Access(org.apache.commons.logging.Log log, AccessLogger accessLogger)
Constructor of AccessLog.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAccessToQueue(org.apache.http.HttpRequest request)
Adds the accesses to the queue.void
addAccessToQueue(org.apache.http.HttpResponse response)
Adds the accesses to the queue.protected Access.AccessLogElement[]
createLogElements()
parse pattern string and create the array of AccessLogElementstatic String
getAcceptCharSetElement(org.apache.http.HttpMessage message)
static String
getAcceptElement(org.apache.http.HttpMessage message)
static String
getAcceptEncodingElement(org.apache.http.HttpMessage message)
static String
getAcceptLanguageElement(org.apache.http.HttpMessage message)
static String
getConnectionElement(org.apache.http.HttpMessage message)
static String
getContentEncodingElement(org.apache.http.HttpMessage message)
static String
getContentTypeElement(org.apache.http.HttpMessage message)
static String
getCookieElement(org.apache.http.HttpMessage message)
protected static String
getHeaderValues(org.apache.http.HttpMessage message, String name)
gets the header values from the given message, with the given name.static String
getHostElement(org.apache.http.HttpMessage message)
static String
getKeepAliveElement(org.apache.http.HttpMessage message)
static String
getLogicalUserNameElement(org.apache.http.HttpMessage message)
protected static String
getParam(org.apache.http.HttpMessage message, String paramName)
static String
getRefererElement(org.apache.http.HttpMessage message)
static String
getRemoteAddr(org.apache.http.HttpMessage message)
static String
getServerElement(org.apache.http.HttpMessage message)
static String
getTransferEncodingElement(org.apache.http.HttpMessage message)
static String
getUserAgentElement(org.apache.http.HttpMessage message)
static String
getUserNameElement(org.apache.http.HttpMessage message)
static String
getVaryElement(org.apache.http.HttpMessage message)
void
log(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
The log method that is called from the NHttpClient and Server connection classes.void
log(HttpRequestWrapper request, HttpResponseWrapper response)
The log method that is called from the NHttpClient and Server connection classes.void
logAccesses()
logs the request and response accesses.
-
-
-
Field Detail
-
logElements
protected Access.AccessLogElement[] logElements
Array of AccessLogElement, they will be used to make log message.
-
pattern
protected String pattern
-
-
Constructor Detail
-
Access
public Access(org.apache.commons.logging.Log log, AccessLogger accessLogger)
Constructor of AccessLog. AccessHandler has a static object of Access.- Parameters:
log
- - Log passed as a param. Default is Log of the same class.accessLogger
- - AccessLogger Object
-
-
Method Detail
-
addAccessToQueue
public void addAccessToQueue(org.apache.http.HttpRequest request)
Adds the accesses to the queue.- Parameters:
request
- - HttpRequest
-
addAccessToQueue
public void addAccessToQueue(org.apache.http.HttpResponse response)
Adds the accesses to the queue.- Parameters:
response
- - HttpResponse
-
logAccesses
public void logAccesses()
logs the request and response accesses.
-
log
public void log(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
The log method that is called from the NHttpClient and Server connection classes.- Parameters:
request
- - HttpRequestresponse
- - HttpResponse
-
getHeaderValues
protected static String getHeaderValues(org.apache.http.HttpMessage message, String name)
gets the header values from the given message, with the given name.- Parameters:
message
- - The message, HttpRequest or HttpResponsename
- - The header, which we need to get the value of.- Returns:
- - The header value.
-
getHostElement
public static String getHostElement(org.apache.http.HttpMessage message)
-
getLogicalUserNameElement
public static String getLogicalUserNameElement(org.apache.http.HttpMessage message)
-
getUserNameElement
public static String getUserNameElement(org.apache.http.HttpMessage message)
-
getCookieElement
public static String getCookieElement(org.apache.http.HttpMessage message)
-
getRefererElement
public static String getRefererElement(org.apache.http.HttpMessage message)
-
getUserAgentElement
public static String getUserAgentElement(org.apache.http.HttpMessage message)
-
getAcceptElement
public static String getAcceptElement(org.apache.http.HttpMessage message)
-
getAcceptLanguageElement
public static String getAcceptLanguageElement(org.apache.http.HttpMessage message)
-
getAcceptEncodingElement
public static String getAcceptEncodingElement(org.apache.http.HttpMessage message)
-
getAcceptCharSetElement
public static String getAcceptCharSetElement(org.apache.http.HttpMessage message)
-
getConnectionElement
public static String getConnectionElement(org.apache.http.HttpMessage message)
-
getContentTypeElement
public static String getContentTypeElement(org.apache.http.HttpMessage message)
-
getKeepAliveElement
public static String getKeepAliveElement(org.apache.http.HttpMessage message)
-
getTransferEncodingElement
public static String getTransferEncodingElement(org.apache.http.HttpMessage message)
-
getContentEncodingElement
public static String getContentEncodingElement(org.apache.http.HttpMessage message)
-
getVaryElement
public static String getVaryElement(org.apache.http.HttpMessage message)
-
getServerElement
public static String getServerElement(org.apache.http.HttpMessage message)
-
getRemoteAddr
public static String getRemoteAddr(org.apache.http.HttpMessage message)
-
createLogElements
protected Access.AccessLogElement[] createLogElements()
parse pattern string and create the array of AccessLogElement- Returns:
- Array of AccessLogElement
-
log
public void log(HttpRequestWrapper request, HttpResponseWrapper response)
The log method that is called from the NHttpClient and Server connection classes. This method is used to log the request/response with the actual date of operation.- Parameters:
request
- - HttpRequestWrapperresponse
- - HttpResponseWrapper
-
-