Updated Branches: refs/heads/wicket-1.5.x 32c236686 -> 881ea3674
WICKET-4900 Setting a status code on an AbstractResource results in no HTTP body Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/881ea367 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/881ea367 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/881ea367 Branch: refs/heads/wicket-1.5.x Commit: 881ea3674fb384eb5121942ef0f7d9aa8891bc1c Parents: 32c2366 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Mon Dec 3 11:20:25 2012 +0100 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Mon Dec 3 11:21:06 2012 +0100 ---------------------------------------------------------------------- .../wicket/request/resource/AbstractResource.java | 19 ++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/881ea367/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java index df883ce..ab63b13 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java @@ -504,7 +504,8 @@ public abstract class AbstractResource implements IResource // set response header setResponseHeaders(data, attributes); - if (!data.dataNeedsToBeWritten(attributes) || data.getErrorCode() != null || data.getStatusCode() != null) + if (!data.dataNeedsToBeWritten(attributes) || data.getErrorCode() != null + || needsBody(data.getStatusCode()) == false) { return; } @@ -518,6 +519,22 @@ public abstract class AbstractResource implements IResource } /** + * Decides whether a response body should be written back to the client depending + * on the set status code + * + * @param statusCode + * the status code set by the application + * @return {@code true} if the status code allows response body, {@code false} - otherwise + */ + private boolean needsBody(Integer statusCode) + { + return statusCode == null || + (statusCode < 300 && + statusCode != HttpServletResponse.SC_NO_CONTENT && + statusCode != HttpServletResponse.SC_RESET_CONTENT); + } + + /** * check if header is directly modifyable * * @param name
