Skip to content

Commit

Permalink
When 'logpost' is set, also ensure request method is POST and body is…
Browse files Browse the repository at this point in the history
… not empty.
  • Loading branch information
briannesbitt committed Apr 25, 2012
1 parent b848ac3 commit cb1344d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/play/modules/accesslog/AccessLogPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,19 @@ private synchronized void log()
line = StringUtils.replaceOnce(line, "%ua", (userAgent != null) ? userAgent.value() : "");
line = StringUtils.replaceOnce(line, "%rt", String.valueOf(requestProcessingTime));

if (_shouldLogPost)
if (_shouldLogPost && request.method.equals("POST"))
{
line = StringUtils.replaceOnce(line, "%post", request.params.get("body"));
String body = request.params.get("body");

if (StringUtils.isNotEmpty(body))
{
line = StringUtils.replaceOnce(line, "%post", body);
}
else
{
// leave quotes in the logged string to show it was an empty POST request
line = StringUtils.remove(line, "%post");
}
}
else
{
Expand Down

0 comments on commit cb1344d

Please sign in to comment.