Skip to content

Commit

Permalink
Merge pull request #12483 from jetty/jetty-12.0.x-12482-CustomRequest…
Browse files Browse the repository at this point in the history
…LogQuery

PR #12482 - fix bug with CustomRequestLog query string
  • Loading branch information
lachlan-roberts authored Nov 7, 2024
2 parents 72f7025 + 9bec2e6 commit 4abbb31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,8 @@ private static void logResponseHeader(String arg, StringBuilder b, Request reque
@SuppressWarnings("unused")
private static void logQueryString(StringBuilder b, Request request, Response response)
{
append(b, "?" + request.getHttpURI().getQuery());
String query = request.getHttpURI().getQuery();
append(b, (query == null) ? null : "?" + query);
}

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,17 @@ public void testLogQueryString() throws Exception
assertThat(log, is("QueryString: ?queryString"));
}

@Test
public void testLogEmptyQueryString() throws Exception
{
start("QueryString: %q");

HttpTester.Response response = getResponse("GET /path HTTP/1.0\n\n");
assertEquals(HttpStatus.OK_200, response.getStatus());
String log = _logs.poll(5, TimeUnit.SECONDS);
assertThat(log, is("QueryString: -"));
}

@Test
public void testLogRequestFirstLine() throws Exception
{
Expand Down

0 comments on commit 4abbb31

Please sign in to comment.