Author: enorman
Date: Thu Aug 5 02:21:23 2010
New Revision: 982453
URL: http://svn.apache.org/viewvc?rev=982453&view=rev
Log:
SLING-1628 Default status code for a post that results in an error should be
500 instead of 200
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java
Modified:
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java?rev=982453&r1=982452&r2=982453&view=diff
==============================================================================
---
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java
(original)
+++
sling/trunk/bundles/api/src/main/java/org/apache/sling/api/servlets/HtmlResponse.java
Thu Aug 5 02:21:23 2010
@@ -214,11 +214,21 @@ public class HtmlResponse {
/**
* Returns the status code of this instance. If the status code has never
* been set by calling the {...@link #setStatus(int, String)} method, the
- * response is assumed to be successful and 200 is returned.
+ * status code is determined by checking if there was an error. If there
+ * was an error, the response is assumed to be unsuccessful and 500 is
returned.
+ * If there is no error, the response is assumed to be successful and 200
is returned.
*/
public int getStatusCode() {
Integer status = getProperty(PN_STATUS_CODE, Integer.class);
- return (status == null) ? HttpServletResponse.SC_OK : status;
+ if (status == null) {
+ if (getError() != null) {
+ //if there was an error
+ status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+ } else {
+ status = HttpServletResponse.SC_OK;
+ }
+ }
+ return status;
}
public String getStatusMessage() {