Issue #1103 original URI trimmed
This commit is contained in:
parent
e1916ab83d
commit
ed14d739f3
|
@ -42,6 +42,7 @@ public class DumpServlet extends HttpServlet
|
||||||
out.println("<h1>DumpServlet</h1>");
|
out.println("<h1>DumpServlet</h1>");
|
||||||
out.println("<pre>");
|
out.println("<pre>");
|
||||||
out.println("requestURI=" + request.getRequestURI());
|
out.println("requestURI=" + request.getRequestURI());
|
||||||
|
out.println("requestURL=" + request.getRequestURL().toString());
|
||||||
out.println("contextPath=" + request.getContextPath());
|
out.println("contextPath=" + request.getContextPath());
|
||||||
out.println("servletPath=" + request.getServletPath());
|
out.println("servletPath=" + request.getServletPath());
|
||||||
out.println("pathInfo=" + request.getPathInfo());
|
out.println("pathInfo=" + request.getPathInfo());
|
||||||
|
|
|
@ -39,10 +39,6 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<!--
|
|
||||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
|
||||||
<artifactId>javax.servlet</artifactId>
|
|
||||||
-->
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
@ -84,4 +80,5 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Locale;
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
|
|
||||||
import org.eclipse.jetty.http.HttpHeader;
|
import org.eclipse.jetty.http.HttpHeader;
|
||||||
import org.eclipse.jetty.http.PathMap;
|
import org.eclipse.jetty.http.pathmap.PathMappings;
|
||||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||||
import org.eclipse.jetty.util.DateCache;
|
import org.eclipse.jetty.util.DateCache;
|
||||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||||
|
@ -54,7 +54,7 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
||||||
|
|
||||||
private String[] _ignorePaths;
|
private String[] _ignorePaths;
|
||||||
private boolean _extended;
|
private boolean _extended;
|
||||||
private transient PathMap<String> _ignorePathMap;
|
private transient PathMappings<String> _ignorePathMap;
|
||||||
private boolean _logLatency = false;
|
private boolean _logLatency = false;
|
||||||
private boolean _logCookies = false;
|
private boolean _logCookies = false;
|
||||||
private boolean _logServer = false;
|
private boolean _logServer = false;
|
||||||
|
@ -222,13 +222,14 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param request request object
|
* Writes extended request and response information to the output stream.
|
||||||
* @param b StringBuilder to write to
|
*
|
||||||
* @throws IOException if unable to append extended log
|
* @param b StringBuilder to write to
|
||||||
* @deprecated override {@link #logExtended(StringBuilder, Request, Response)} instead
|
* @param request request object
|
||||||
|
* @param response response object
|
||||||
|
* @throws IOException if unable to log the extended information
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
protected void logExtended(StringBuilder b, Request request, Response response) throws IOException
|
||||||
protected void logExtended(Request request, StringBuilder b) throws IOException
|
|
||||||
{
|
{
|
||||||
String referer = request.getHeader(HttpHeader.REFERER.toString());
|
String referer = request.getHeader(HttpHeader.REFERER.toString());
|
||||||
if (referer == null)
|
if (referer == null)
|
||||||
|
@ -251,19 +252,6 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes extended request and response information to the output stream.
|
|
||||||
*
|
|
||||||
* @param b StringBuilder to write to
|
|
||||||
* @param request request object
|
|
||||||
* @param response response object
|
|
||||||
* @throws IOException if unable to log the extended information
|
|
||||||
*/
|
|
||||||
protected void logExtended(StringBuilder b, Request request, Response response) throws IOException
|
|
||||||
{
|
|
||||||
logExtended(request, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set request paths that will not be logged.
|
* Set request paths that will not be logged.
|
||||||
*
|
*
|
||||||
|
@ -423,7 +411,7 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
||||||
|
|
||||||
if (_ignorePaths != null && _ignorePaths.length > 0)
|
if (_ignorePaths != null && _ignorePaths.length > 0)
|
||||||
{
|
{
|
||||||
_ignorePathMap = new PathMap<>();
|
_ignorePathMap = new PathMappings<>();
|
||||||
for (int i = 0; i < _ignorePaths.length; i++)
|
for (int i = 0; i < _ignorePaths.length; i++)
|
||||||
_ignorePathMap.put(_ignorePaths[i], _ignorePaths[i]);
|
_ignorePathMap.put(_ignorePaths[i], _ignorePaths[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1734,9 +1734,10 @@ public class Request implements HttpServletRequest
|
||||||
public void setMetaData(org.eclipse.jetty.http.MetaData.Request request)
|
public void setMetaData(org.eclipse.jetty.http.MetaData.Request request)
|
||||||
{
|
{
|
||||||
_metaData=request;
|
_metaData=request;
|
||||||
_originalURI=_metaData.getURIString();
|
|
||||||
setMethod(request.getMethod());
|
setMethod(request.getMethod());
|
||||||
HttpURI uri = request.getURI();
|
HttpURI uri = request.getURI();
|
||||||
|
_originalURI=uri.isAbsolute()&&request.getHttpVersion()!=HttpVersion.HTTP_2?uri.toString():uri.getPathQuery();
|
||||||
|
|
||||||
String path = uri.getDecodedPath();
|
String path = uri.getDecodedPath();
|
||||||
String info;
|
String info;
|
||||||
|
|
|
@ -80,9 +80,7 @@ public class RequestLogTest
|
||||||
{
|
{
|
||||||
_connector.getResponse("GET /foo?data=1 HTTP/1.0\nhost: host:80\n\n");
|
_connector.getResponse("GET /foo?data=1 HTTP/1.0\nhost: host:80\n\n");
|
||||||
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
// TODO should be without host (https://bugs.eclipse.org/bugs/show_bug.cgi?id=480276)
|
assertThat(log,containsString("GET /foo?data=1 HTTP/1.0\" 200 "));
|
||||||
// assertThat(log,containsString("GET /foo?data=1 HTTP/1.0\" 200 "));
|
|
||||||
assertThat(log,containsString("GET //host:80/foo?data=1 HTTP/1.0\" 200 "));
|
|
||||||
|
|
||||||
_connector.getResponse("GET //bad/foo?data=1 HTTP/1.0\n\n");
|
_connector.getResponse("GET //bad/foo?data=1 HTTP/1.0\n\n");
|
||||||
log = _log.exchange(null,5,TimeUnit.SECONDS);
|
log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
@ -93,6 +91,51 @@ public class RequestLogTest
|
||||||
assertThat(log,containsString("GET http://host:80/foo?data=1 HTTP/1.0\" 200 "));
|
assertThat(log,containsString("GET http://host:80/foo?data=1 HTTP/1.0\" 200 "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHTTP10Host() throws Exception
|
||||||
|
{
|
||||||
|
_connector.getResponse(
|
||||||
|
"GET /foo?name=value HTTP/1.0\n"+
|
||||||
|
"Host: servername\n"+
|
||||||
|
"\n");
|
||||||
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
assertThat(log,containsString("GET /foo?name=value"));
|
||||||
|
assertThat(log,containsString(" 200 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHTTP11() throws Exception
|
||||||
|
{
|
||||||
|
_connector.getResponse(
|
||||||
|
"GET /foo?name=value HTTP/1.1\n"+
|
||||||
|
"Host: servername\n"+
|
||||||
|
"\n");
|
||||||
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
assertThat(log,containsString("GET /foo?name=value"));
|
||||||
|
assertThat(log,containsString(" 200 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAbsolute() throws Exception
|
||||||
|
{
|
||||||
|
_connector.getResponse(
|
||||||
|
"GET http://hostname:8888/foo?name=value HTTP/1.1\n"+
|
||||||
|
"Host: servername\n"+
|
||||||
|
"\n");
|
||||||
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
assertThat(log,containsString("GET http://hostname:8888/foo?name=value"));
|
||||||
|
assertThat(log,containsString(" 200 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testQuery() throws Exception
|
||||||
|
{
|
||||||
|
_connector.getResponse("GET /foo?name=value HTTP/1.0\n\n");
|
||||||
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
assertThat(log,containsString("GET /foo?name=value"));
|
||||||
|
assertThat(log,containsString(" 200 "));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSmallData() throws Exception
|
public void testSmallData() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -1429,13 +1430,12 @@ public class XmlConfiguration
|
||||||
*/
|
*/
|
||||||
public static void main(final String... args) throws Exception
|
public static void main(final String... args) throws Exception
|
||||||
{
|
{
|
||||||
final AtomicReference<Throwable> exception = new AtomicReference<>();
|
try
|
||||||
|
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Object>()
|
|
||||||
{
|
{
|
||||||
public Object run()
|
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>()
|
||||||
{
|
{
|
||||||
try
|
@Override
|
||||||
|
public Void run() throws Exception
|
||||||
{
|
{
|
||||||
Properties properties = null;
|
Properties properties = null;
|
||||||
|
|
||||||
|
@ -1509,26 +1509,15 @@ public class XmlConfiguration
|
||||||
lc.start();
|
lc.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOG.debug(Log.EXCEPTION,e);
|
|
||||||
exception.set(e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Throwable th = exception.get();
|
return null;
|
||||||
if (th != null)
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Error|Exception e)
|
||||||
{
|
{
|
||||||
if (th instanceof RuntimeException)
|
LOG.warn(e);
|
||||||
throw (RuntimeException)th;
|
throw e;
|
||||||
else if (th instanceof Exception)
|
|
||||||
throw (Exception)th;
|
|
||||||
else if (th instanceof Error)
|
|
||||||
throw (Error)th;
|
|
||||||
throw new Error(th);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue