luetzkendorf    2004/08/03 07:58:23

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        GetMethod.java
  Log:
  invalid ranges now throw  WebdavExceptions to avoid IllegalStateEception
  while writing to the response after sendError
  
  Revision  Changes    Path
  1.50      +19 -16    
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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- GetMethod.java    2 Aug 2004 16:36:01 -0000       1.49
  +++ GetMethod.java    3 Aug 2004 14:58:23 -0000       1.50
  @@ -567,12 +567,13 @@
        *
        * @param request The servlet request we are processing
        * @param response The servlet response we are creating
  -     * @return Vector of ranges
  +     * @return Vector of ranges or <code>null</code> of no ranges are requested
  +     * @throws WebdavException if the range request is wrong
        */
       private Vector parseRange(HttpServletRequest request,
                                 HttpServletResponse response,
                                 ResourceInfo resourceInfo)
  -        throws IOException 
  +        throws IOException, WebdavException 
       {
           
           // Retrieving the range header (if any is specified)
  @@ -621,7 +622,8 @@
           if (!rangeHeader.startsWith("bytes")) {
               response.sendError
                   (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  -            return null;
  +            throw new WebdavException(
  +                     HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
           }
           rangeHeader = rangeHeader.substring(6);
   
  @@ -643,7 +645,8 @@
               if (dashPos == -1) {
                   response.sendError
                       (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  -                return null;
  +                throw new WebdavException(
  +                             
HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
               }
   
               if (dashPos == 0) {
  @@ -653,10 +656,10 @@
                       currentRange.start = fileLength + offset;
                       currentRange.end = fileLength - 1;
                   } catch (NumberFormatException e) {
  -                    response.sendError
  -                        (HttpServletResponse
  -                             .SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  -                    return null;
  +                    response.sendError(
  +                        HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  +                    throw new WebdavException(
  +                             
HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
                   }
   
               } else {
  @@ -671,10 +674,10 @@
                       else
                           currentRange.end = fileLength - 1;
                   } catch (NumberFormatException e) {
  -                    response.sendError
  -                        (HttpServletResponse
  -                             .SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  -                    return null;
  +                    response.sendError(
  +                             
HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  +                    throw new WebdavException(
  +                             
HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
                   }
   
               }
  @@ -683,7 +686,7 @@
               if (!currentRange.validate()) {
                   response.sendError
                       (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  -                return null;
  +                throw new 
WebdavException(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
               }
   
               result.addElement(currentRange);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to