tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets DefaultServlet.java
Date Tue, 01 Jan 2002 21:30:48 GMT
remm        02/01/01 13:30:48

  Modified:    catalina/src/share/org/apache/catalina/servlets
                        DefaultServlet.java
  Log:
  - Fix bugs 5617 and 5618.
  - Fix incorrect content length (off by one byte) when a partial content
    is returned.
  
  Revision  Changes    Path
  1.48      +16 -7     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
  
  Index: DefaultServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- DefaultServlet.java	21 Dec 2001 21:15:45 -0000	1.47
  +++ DefaultServlet.java	1 Jan 2002 21:30:48 -0000	1.48
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.47 2001/12/21 21:15:45 craigmcc Exp $
  - * $Revision: 1.47 $
  - * $Date: 2001/12/21 21:15:45 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.48 2002/01/01 21:30:48 remm Exp $
  + * $Revision: 1.48 $
  + * $Date: 2002/01/01 21:30:48 $
    *
    * ====================================================================
    *
  @@ -125,7 +125,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.47 $ $Date: 2001/12/21 21:15:45 $
  + * @version $Revision: 1.48 $ $Date: 2002/01/01 21:30:48 $
    */
   
   public class DefaultServlet
  @@ -1312,7 +1312,7 @@
                                      + range.start
                                      + "-" + range.end + "/"
                                      + range.length);
  -                response.setContentLength((int) (range.end - range.start));
  +                response.setContentLength((int) (range.end - range.start + 1));
   
                   if (contentType != null) {
                       if (debug > 0)
  @@ -1484,6 +1484,7 @@
           // bytes is the only range unit supported (and I don't see the point
           // of adding new ones).
           if (!rangeHeader.startsWith("bytes")) {
  +            response.addHeader("Content-Range", "bytes */" + fileLength);
               response.sendError
                   (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
               return null;
  @@ -1506,6 +1507,7 @@
               int dashPos = rangeDefinition.indexOf('-');
   
               if (dashPos == -1) {
  +                response.addHeader("Content-Range", "bytes */" + fileLength);
                   response.sendError
                       (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
                   return null;
  @@ -1518,6 +1520,8 @@
                       currentRange.start = fileLength + offset;
                       currentRange.end = fileLength - 1;
                   } catch (NumberFormatException e) {
  +                    response.addHeader("Content-Range", 
  +                                       "bytes */" + fileLength);
                       response.sendError
                           (HttpServletResponse
                            .SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  @@ -1536,6 +1540,8 @@
                       else
                           currentRange.end = fileLength - 1;
                   } catch (NumberFormatException e) {
  +                    response.addHeader("Content-Range", 
  +                                       "bytes */" + fileLength);
                       response.sendError
                           (HttpServletResponse
                            .SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  @@ -1545,6 +1551,7 @@
               }
   
               if (!currentRange.validate()) {
  +                response.addHeader("Content-Range", "bytes */" + fileLength);
                   response.sendError
                       (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
                   return null;
  @@ -2243,8 +2250,10 @@
            * Validate range.
            */
           public boolean validate() {
  -            return ( (start >= 0) && (end >= 0) && (start <= end)

  -                     && (length > 0) && (end < length) );
  +            if (end >= length)
  +                end = length - 1;
  +            return ( (start >= 0) && (end >= 0) && (start <= end)
  +                     && (length > 0) );
           }
   
           public void recycle() {
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message