コード例 #1
0
  @Override
  public void handle(
      String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    HttpServletRequestWrapper modifiedRequest =
        new HttpServletRequestWrapper(request) { // Prevent NOT_MODIFIED_SINCE 304 response
          private static final long WAS_MODIFIED = -1;

          @Override
          public long getDateHeader(String name) {
            HttpServletRequest request = (HttpServletRequest) getRequest();

            if (HttpHeaders.IF_MODIFIED_SINCE.equals(name)) {
              return WAS_MODIFIED;
            }
            return request.getDateHeader(name);
          };
        };

    HttpServletResponseWrapper modifiedResponce =
        new HttpServletResponseWrapper(response) { // Prevent "if-modified-since" headers handling

          @Override
          public void setDateHeader(String name, long date) {}
        };

    super.handle(target, baseRequest, modifiedRequest, modifiedResponce);
  }
コード例 #2
0
 @Override
 public void handle(
     String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {
   final String suffix = RequestPath.suffix(target);
   final String path = path(suffix);
   if (!paths.contains(path)) {
     if (!whitelist.contains(suffix)) return;
     if (!"GET".equals(baseRequest.getMethod()))
       baseRequest.setMethod(HttpMethod.GET, HttpMethod.GET.toString());
     super.handle(target, baseRequest, request, allowCrossOrigin(response));
   } else {
     baseRequest
         .getContext()
         .getContext(path)
         .getRequestDispatcher(target)
         .forward(request, allowCrossOrigin(response));
   }
 }