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.
  • Field Details

    • logElements

      protected Access.AccessLogElement[] logElements
      Array of AccessLogElement, they will be used to make log message.
    • pattern

      protected String pattern
  • Constructor Details

    • 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 Details

    • 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
    • addCombinedAccessToQueue

      public void addCombinedAccessToQueue(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
      Adds a correlated request+response pair to the combined queue for single-line logging.
      Parameters:
      request - - HttpRequest
      response - - HttpResponse
    • incrementBodyBytes

      public static void incrementBodyBytes(org.apache.http.HttpMessage message, String paramName, long bytes)
      Adds the given number of body bytes to the counter kept in the message params. Used to calculate the message size when it is not available in the Content-Length header (e.g. chunked messages).
      Parameters:
      message - - HttpRequest or HttpResponse whose body bytes were transferred
      paramName - - HTTP_REQUEST_BODY_BYTES or HTTP_RESPONSE_BODY_BYTES
      bytes - - number of body bytes transferred
    • 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 - - HttpRequest
      response - - HttpResponse
    • logCombined

      public void logCombined(HttpRequestWrapper request, HttpResponseWrapper response)
      Logs request and response as a single combined log line.
      Parameters:
      request - - HttpRequestWrapper
      response - - HttpResponseWrapper
    • 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 HttpResponse
      name - - The header, which we need to get the value of.
      Returns:
      - The header value.
    • getParam

      protected static String getParam(org.apache.http.HttpMessage message, String paramName)
    • 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 - - HttpRequestWrapper
      response - - HttpResponseWrapper