Updated Branches: refs/heads/master 983ecc70d -> 085c37c3f
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/085c37c3 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/085c37c3 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/085c37c3 Branch: refs/heads/master Commit: 085c37c3fcaecfd8a2ebc11f2732a27d1f633cbb Parents: 983ecc7 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:20:25 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/085c37c3/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 f91c61e..ecfc444 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 @@ -512,7 +512,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; } @@ -533,6 +534,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
