mirror of
https://github.com/jetty/jetty.project.git
synced 2025-02-25 00:45:18 +00:00
Fix NCSA request log in case of missing useragent. (#770)
Signed-off-by: Niels Basjes <niels@basjes.nl>
This commit is contained in:
parent
64faccfda6
commit
c8c253d6ae
@ -242,7 +242,7 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement
|
|||||||
|
|
||||||
String agent = request.getHeader(HttpHeader.USER_AGENT.toString());
|
String agent = request.getHeader(HttpHeader.USER_AGENT.toString());
|
||||||
if (agent == null)
|
if (agent == null)
|
||||||
b.append("\"-\" ");
|
b.append("\"-\"");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
b.append('"');
|
b.append('"');
|
||||||
|
@ -188,11 +188,31 @@ public class RequestLogTest
|
|||||||
assertThat(log,containsString("GET /foo "));
|
assertThat(log,containsString("GET /foo "));
|
||||||
assertThat(log,containsString(" 400 0 "));
|
assertThat(log,containsString(" 400 0 "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUseragentWithout() throws Exception
|
||||||
|
{
|
||||||
|
_connector.getResponses("GET http://[:1]/foo HTTP/1.1\nReferer: http://other.site\n\n");
|
||||||
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
assertThat(log,containsString("GET http://[:1]/foo "));
|
||||||
|
assertThat(log,containsString(" 400 0 \"http://other.site\" \"-\" - "));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUseragentWith() throws Exception
|
||||||
|
{
|
||||||
|
_connector.getResponses("GET http://[:1]/foo HTTP/1.1\nReferer: http://other.site\nUser-Agent: Mozilla/5.0 (test)\n\n");
|
||||||
|
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||||
|
assertThat(log,containsString("GET http://[:1]/foo "));
|
||||||
|
assertThat(log,containsString(" 400 0 \"http://other.site\" \"Mozilla/5.0 (test)\" - "));
|
||||||
|
}
|
||||||
|
|
||||||
private class Log extends AbstractNCSARequestLog
|
private class Log extends AbstractNCSARequestLog
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
super.setExtended(true);
|
super.setExtended(true);
|
||||||
|
super.setLogLatency(true);
|
||||||
|
super.setLogCookies(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user