You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by oz...@apache.org on 2004/09/23 10:19:15 UTC
cvs commit: jakarta-slide/src/webdav/server/org/apache/slide/webdav/method GetMethod.java
ozeigermann 2004/09/23 01:19:15
Modified: src/webdav/server/org/apache/slide/webdav/util
WebdavUtils.java
src/webdav/server/org/apache/slide/webdav/method
GetMethod.java
Log:
Requests canceled by the client side or now are handeled a bit more gracefully.
Instead of issuing internal errors now for both PUT and GET you get a
precodition failed response code and now worrying stack traces
Revision Changes Path
1.27 +12 -5 jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WebdavUtils.java
Index: WebdavUtils.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/WebdavUtils.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- WebdavUtils.java 8 Sep 2004 04:14:31 -0000 1.26
+++ WebdavUtils.java 23 Sep 2004 08:19:14 -0000 1.27
@@ -23,6 +23,7 @@
package org.apache.slide.webdav.util;
+import java.net.SocketException;
import java.security.Principal;
import java.io.UnsupportedEncodingException;
@@ -556,10 +557,16 @@
*/
public static int getErrorCode(ServiceAccessException ex) {
Throwable cause = ex.getCauseException();
- if (cause == null || !(cause instanceof SlideException) ) {
+ // XXX SocketException pops up when the client closes the connection in the middle of transferring
+ // the HTTP body, so this is no internal error, really!
+ if (cause != null && cause instanceof SocketException) {
+ // XXX is this a reasonable code?
+ return WebdavStatus.SC_PRECONDITION_FAILED;
+ } else if (cause == null || !(cause instanceof SlideException)) {
// ex.printStackTrace();
if( cause != null ) cause.printStackTrace();
return WebdavStatus.SC_INTERNAL_SERVER_ERROR; // this is the default}
+
} else {
return getErrorCode((SlideException)cause);
}
1.52 +14 -4 jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java
Index: GetMethod.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/GetMethod.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- GetMethod.java 5 Aug 2004 14:43:29 -0000 1.51
+++ GetMethod.java 23 Sep 2004 08:19:14 -0000 1.52
@@ -287,7 +287,17 @@
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
} catch (Exception e) {
- int statusCode = getErrorCode( e );
+ int statusCode;
+ // XXX If there is some sort of IOException it has been issued by the copy methods
+ // which indicates the client aborted the connection
+ // like org.apache.catalina.connector.ClientAbortException thrown by Tomcat
+ if (e instanceof IOException) {
+ // XXX like in WebdavUtils which reacts on a failure upon put, we use this return method,
+ // however, is it sensible?
+ statusCode = WebdavStatus.SC_PRECONDITION_FAILED;
+ } else {
+ statusCode = getErrorCode( e );
+ }
sendError( statusCode, e );
throw new WebdavException( statusCode );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org