tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/modules/generators StaticInterceptor.java
Date Sat, 24 Mar 2001 19:48:32 GMT
nacho       01/03/24 11:48:32

  Modified:    src/share/org/apache/tomcat/modules/generators
                        StaticInterceptor.java
  Log:
  Honoring the "If-Modified-Since" header..
  No more "Connection Broken Exceptions" in logs
  when using IE .
  
  Revision  Changes    Path
  1.8       +37 -2     jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java
  
  Index: StaticInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/generators/StaticInterceptor.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- StaticInterceptor.java	2001/03/14 05:57:48	1.7
  +++ StaticInterceptor.java	2001/03/24 19:48:32	1.8
  @@ -240,7 +240,15 @@
   final class FileHandler extends Handler  {
       int realFileNote;
       Context context;
  -    
  +    /**
  +     * The set of SimpleDateFormat formats to use in getDateHeader().
  +     */
  +    protected static final SimpleDateFormat formats[] = {
  +	new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
  +	new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
  +	new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US)
  +    };
  +
       FileHandler() {
   	//	setOrigin( Handler.ORIGIN_INTERNAL );
   	name="tomcat.fileHandler";
  @@ -283,8 +291,35 @@
   	}
   
   	File file = new File( absPath );
  +        String headerValue=req.getHeader("If-Modified-Since");
  +/**/
  +        headerValue = req.getHeader("If-Modified-Since");
  +        if (headerValue != null) {
  +
  +            Date date = null;
  +
  +            // Parsing the HTTP Date
  +            for (int i = 0; (date == null) && (i < formats.length); i++) {
  +                try {
  +                    date = formats[i].parse(headerValue);
  +                } catch (ParseException e) {
  +                    ;
  +                }
  +            }
  +
  +            if ((date != null)
  +                && (file.lastModified() <= (date.getTime() + 1000)) ) {
  +                // The entity has not been modified since the date
  +                // specified by the client. This is not an error case.
  +                context.getContextManager().handleStatus( req, res, 304);
  +                return;
  +            }
  +
  +
  +        }
  +/**/
   	if( debug>0) log( "After paranoic checks = " + absPath);
  -	
  +
           String mimeType=ctx.getMimeMap().getContentTypeFor(absPath);
   
   	if (mimeType == null) {
  
  
  

Mime
View raw message