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 Wed, 02 Jan 2002 20:37:32 GMT
remm        02/01/02 12:37:32

  Modified:    catalina/src/share/org/apache/catalina/servlets Tag:
                        tomcat_40_branch DefaultServlet.java
  Log:
  - Port fix for bugs 5617 and 5618.
  - Fix incorrect content length (off by one byte) when a partial content
    is returned.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.39.2.4  +15 -6     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.39.2.3
  retrieving revision 1.39.2.4
  diff -u -r1.39.2.3 -r1.39.2.4
  --- DefaultServlet.java	20 Dec 2001 12:25:07 -0000	1.39.2.3
  +++ DefaultServlet.java	2 Jan 2002 20:37:32 -0000	1.39.2.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.39.2.3 2001/12/20 12:25:07 remm Exp $
  - * $Revision: 1.39.2.3 $
  - * $Date: 2001/12/20 12:25:07 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java,v
1.39.2.4 2002/01/02 20:37:32 remm Exp $
  + * $Revision: 1.39.2.4 $
  + * $Date: 2002/01/02 20:37:32 $
    *
    * ====================================================================
    *
  @@ -122,7 +122,7 @@
    *
    * @author Craig R. McClanahan
    * @author Remy Maucherat
  - * @version $Revision: 1.39.2.3 $ $Date: 2001/12/20 12:25:07 $
  + * @version $Revision: 1.39.2.4 $ $Date: 2002/01/02 20:37:32 $
    */
   
   public class DefaultServlet
  @@ -1216,7 +1216,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)
  @@ -1327,6 +1327,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;
  @@ -1349,6 +1350,7 @@
               int dashPos = rangeDefinition.indexOf('-');
   
               if (dashPos == -1) {
  +                response.addHeader("Content-Range", "bytes */" + fileLength);
                   response.sendError
                       (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
                   return null;
  @@ -1361,6 +1363,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);
  @@ -1379,6 +1383,8 @@
                       else
                           currentRange.end = fileLength - 1;
                   } catch (NumberFormatException e) {
  +                    response.addHeader
  +                        ("Content-Range", "bytes */" + fileLength);
                       response.sendError
                           (HttpServletResponse
                            .SC_REQUESTED_RANGE_NOT_SATISFIABLE);
  @@ -1388,6 +1394,7 @@
               }
   
               if (!currentRange.validate()) {
  +                response.addHeader("Content-Range", "bytes */" + fileLength);
                   response.sendError
                       (HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE);
                   return null;
  @@ -2089,8 +2096,10 @@
            * Validate range.
            */
           public boolean validate() {
  +            if (end >= length)
  +                end = length - 1;
               return ( (start >= 0) && (end >= 0) && (length > 0)
  -                     && (start <= end) && (end < length) );
  +                     && (start <= end) );
           }
   
           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