コード例 #1
0
 public boolean rewrite(HttpRequest request, HttpResponse resp, MutableContent content) {
   // Content fetched through the proxy can stipulate that it must be sanitized.
   if (request.isSanitizationRequested()) {
     ContentRewriterFeature rewriterFeature =
         rewriterFeatureFactory.createRewriteAllFeature(request.getCacheTtl());
     if (StringUtils.isEmpty(request.getRewriteMimeType())) {
       logger.log(
           Level.WARNING, "Request to sanitize without content type for " + request.getUri());
       content.setContent("");
       return true;
     } else if (request.getRewriteMimeType().equalsIgnoreCase("text/css")) {
       return rewriteProxiedCss(request, resp, content, rewriterFeature);
     } else if (request.getRewriteMimeType().toLowerCase().startsWith("image/")) {
       return rewriteProxiedImage(request, resp, content);
     } else {
       logger.log(
           Level.WARNING,
           "Request to sanitize unknown content type "
               + request.getRewriteMimeType()
               + " for "
               + request.getUri());
       content.setContent("");
       return true;
     }
   } else {
     // No Op
     return false;
   }
 }
コード例 #2
0
 @Override
 public boolean equals(Object obj) {
   if (obj == this) {
     return true;
   }
   if (!(obj instanceof HttpRequest)) {
     return false;
   }
   HttpRequest req = (HttpRequest) obj;
   return super.equals(obj)
       && req.getCacheTtl() == getCacheTtl()
       && req.getIgnoreCache() == getIgnoreCache();
 }