1 16 package org.mortbay.http.handler; 17 18 import java.io.IOException ; 19 20 import org.apache.commons.logging.Log; 21 import org.mortbay.log.LogFactory; 22 import org.mortbay.http.HttpException; 23 import org.mortbay.http.HttpFields; 24 import org.mortbay.http.HttpRequest; 25 import org.mortbay.http.HttpResponse; 26 27 28 34 public class ExpiryHandler extends AbstractHttpHandler 35 { 36 private static Log log = LogFactory.getLog(ExpiryHandler.class); 37 38 41 private long _ttl=-1; 42 43 44 50 public void setTimeToLive(long ttl) 51 { 52 _ttl=ttl; 53 } 54 55 56 68 public void handle(String pathInContext, 69 String pathParams, 70 HttpRequest request, 71 HttpResponse response) 72 throws HttpException,IOException 73 { 74 log.debug("ExpiryHandler.handle()"); 75 String expires; 76 if (_ttl<0) 77 expires=HttpFields.__01Jan1970; 78 else 79 expires=HttpFields.formatDate 80 (System.currentTimeMillis()+1000L*_ttl,false); 81 response.setField(HttpFields.__Expires,expires); 82 } 83 } 84 | Popular Tags |