From 834a8ae734c7af26826962d52e1aace2bd7bbef3 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 03 May 2013 12:33:08 +0000
Subject: [PATCH] OPENDJ-879 (CR-1642) Add HTTP access log
---
opends/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java b/opends/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
index 04188dc..ff2a1d5 100644
--- a/opends/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
+++ b/opends/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
@@ -33,6 +33,8 @@
import java.util.LinkedHashSet;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.servlet.http.HttpServletResponse;
+
import org.forgerock.opendj.ldap.AbstractAsynchronousConnection;
import org.forgerock.opendj.ldap.ConnectionEventListener;
import org.forgerock.opendj.ldap.ErrorResultException;
@@ -68,6 +70,7 @@
import org.opends.server.core.QueueingStrategy;
import org.opends.server.core.SearchOperationBasis;
import org.opends.server.core.UnbindOperationBasis;
+import org.opends.server.loggers.HTTPRequestInfo;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.ByteString;
@@ -91,6 +94,9 @@
/** The HTTP client connection being "adapted". */
private final HTTPClientConnection clientConnection;
+ /** The HTTP request information to log. */
+ private final HTTPRequestInfo requestInfo;
+
/**
* The next message ID (and operation ID) that should be used for this
* connection.
@@ -111,10 +117,14 @@
*
* @param clientConnection
* the HTTP client connection being "adapted"
+ * @param requestInfo
+ * the HTTP request information to log
*/
- public SdkConnectionAdapter(HTTPClientConnection clientConnection)
+ public SdkConnectionAdapter(HTTPClientConnection clientConnection,
+ HTTPRequestInfo requestInfo)
{
this.clientConnection = clientConnection;
+ this.requestInfo = requestInfo;
this.queueingStrategy =
new BoundedWorkQueueStrategy(clientConnection.getConnectionHandler()
.getCurrentConfig().getMaxConcurrentOpsPerConnection());
@@ -223,6 +233,11 @@
{
this.clientConnection.disconnect(DisconnectReason.UNBIND, false, null);
}
+
+ // At this point, we try to log the request with OK status code.
+ // If it was already logged, it will be a no op.
+ this.requestInfo.log(HttpServletResponse.SC_OK);
+
isClosed = true;
}
--
Gitblit v1.10.0