@Test public void testNonWSDLRequest() throws IOException, ServletException { when(httpServletResponse.getOutputStream()).thenReturn(sos); handler.doHandle("/foo.wsdl", request, request, httpServletResponse); assertTrue(request.isHandled()); verify(httpServletResponse).setStatus(HttpServletResponse.SC_NOT_FOUND); logCheck(); }
@Override public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { LOGGER.debug("Static content stream handler for context path {} invoked for request path {}", getContextPath(), target); baseRequest.setHandled(true); final RequestTimer timer = new RequestTimer(); response.setHeader("Server", VERSION_HEADER); long bytesWritten = 0; ResponseCode responseCode = ResponseCode.Ok; if (IS_STATIC_CONTENT_PATH.matcher(target).matches()) { try { InputStream rawStream = getClass().getResourceAsStream(target); if (rawStream != null) { LOGGER.debug("Static content stream found for path {}", target); bytesWritten = ServletResponseFileStreamer.getInstance().streamFileToResponse(rawStream, response, HttpServletResponse.SC_OK, getContentType(contentType, target), CACHE_CONTROL_HEADER ); numOK.incrementAndGet(); } else { LOGGER.debug("Static content stream not found for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } } catch (IOException e) { ioErrorsEncountered.incrementAndGet(); LOGGER.debug("Failed to marshall static data to the output channel.", e); } catch (Exception e) { LOGGER.error("Unexpected Exception thrown processing WSDL request", e); responseCode = ResponseCode.InternalError; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); numErrors.incrementAndGet(); } } else { LOGGER.debug("Static content stream did not match regex for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } logAccess(request, response, bytesWritten, responseCode, timer); }
StaticContentServiceHandler extends ContextHandler { @Override public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { LOGGER.debug("Static content stream handler for context path {} invoked for request path {}", getContextPath(), target); baseRequest.setHandled(true); final RequestTimer timer = new RequestTimer(); response.setHeader("Server", VERSION_HEADER); long bytesWritten = 0; ResponseCode responseCode = ResponseCode.Ok; if (IS_STATIC_CONTENT_PATH.matcher(target).matches()) { try { InputStream rawStream = getClass().getResourceAsStream(target); if (rawStream != null) { LOGGER.debug("Static content stream found for path {}", target); bytesWritten = ServletResponseFileStreamer.getInstance().streamFileToResponse(rawStream, response, HttpServletResponse.SC_OK, getContentType(contentType, target), CACHE_CONTROL_HEADER ); numOK.incrementAndGet(); } else { LOGGER.debug("Static content stream not found for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } } catch (IOException e) { ioErrorsEncountered.incrementAndGet(); LOGGER.debug("Failed to marshall static data to the output channel.", e); } catch (Exception e) { LOGGER.error("Unexpected Exception thrown processing WSDL request", e); responseCode = ResponseCode.InternalError; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); numErrors.incrementAndGet(); } } else { LOGGER.debug("Static content stream did not match regex for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } logAccess(request, response, bytesWritten, responseCode, timer); } }
StaticContentServiceHandler extends ContextHandler { @Override public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { LOGGER.debug("Static content stream handler for context path {} invoked for request path {}", getContextPath(), target); baseRequest.setHandled(true); final RequestTimer timer = new RequestTimer(); response.setHeader("Server", VERSION_HEADER); long bytesWritten = 0; ResponseCode responseCode = ResponseCode.Ok; if (IS_STATIC_CONTENT_PATH.matcher(target).matches()) { try { InputStream rawStream = getClass().getResourceAsStream(target); if (rawStream != null) { LOGGER.debug("Static content stream found for path {}", target); bytesWritten = ServletResponseFileStreamer.getInstance().streamFileToResponse(rawStream, response, HttpServletResponse.SC_OK, getContentType(contentType, target), CACHE_CONTROL_HEADER ); numOK.incrementAndGet(); } else { LOGGER.debug("Static content stream not found for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } } catch (IOException e) { ioErrorsEncountered.incrementAndGet(); LOGGER.debug("Failed to marshall static data to the output channel.", e); } catch (Exception e) { LOGGER.error("Unexpected Exception thrown processing WSDL request", e); responseCode = ResponseCode.InternalError; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); numErrors.incrementAndGet(); } } else { LOGGER.debug("Static content stream did not match regex for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } logAccess(request, response, bytesWritten, responseCode, timer); } StaticContentServiceHandler(
					String contextPath,
					String staticContentRegex,
					String contentType,
                    String uuidHeader,
                    String uuidParentsHeader,
                    GeoLocationDeserializer deserializer,
					GeoIPLocator geoIPLocator,
                    RequestLogger requestLogger,
                    boolean suppressCommasInAccessLog); }
StaticContentServiceHandler extends ContextHandler { @Override public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { LOGGER.debug("Static content stream handler for context path {} invoked for request path {}", getContextPath(), target); baseRequest.setHandled(true); final RequestTimer timer = new RequestTimer(); response.setHeader("Server", VERSION_HEADER); long bytesWritten = 0; ResponseCode responseCode = ResponseCode.Ok; if (IS_STATIC_CONTENT_PATH.matcher(target).matches()) { try { InputStream rawStream = getClass().getResourceAsStream(target); if (rawStream != null) { LOGGER.debug("Static content stream found for path {}", target); bytesWritten = ServletResponseFileStreamer.getInstance().streamFileToResponse(rawStream, response, HttpServletResponse.SC_OK, getContentType(contentType, target), CACHE_CONTROL_HEADER ); numOK.incrementAndGet(); } else { LOGGER.debug("Static content stream not found for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } } catch (IOException e) { ioErrorsEncountered.incrementAndGet(); LOGGER.debug("Failed to marshall static data to the output channel.", e); } catch (Exception e) { LOGGER.error("Unexpected Exception thrown processing WSDL request", e); responseCode = ResponseCode.InternalError; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); numErrors.incrementAndGet(); } } else { LOGGER.debug("Static content stream did not match regex for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } logAccess(request, response, bytesWritten, responseCode, timer); } StaticContentServiceHandler(
					String contextPath,
					String staticContentRegex,
					String contentType,
                    String uuidHeader,
                    String uuidParentsHeader,
                    GeoLocationDeserializer deserializer,
					GeoIPLocator geoIPLocator,
                    RequestLogger requestLogger,
                    boolean suppressCommasInAccessLog); @Override void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response); @ManagedAttribute @Override String getContextPath(); @ManagedAttribute long getNumOKRequests(); @ManagedAttribute long getNumErrors(); @ManagedAttribute long getNumNotFound(); @ManagedAttribute String getContentType(); void setUnknownCipherKeyLength(int unknownCipherKeyLength); @ManagedAttribute int getUnknownCipherKeyLength(); @ManagedAttribute boolean isSuppressCommasInAccessLog(); @ManagedAttribute boolean isEscapeCommasInAccessLog(); }
StaticContentServiceHandler extends ContextHandler { @Override public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { LOGGER.debug("Static content stream handler for context path {} invoked for request path {}", getContextPath(), target); baseRequest.setHandled(true); final RequestTimer timer = new RequestTimer(); response.setHeader("Server", VERSION_HEADER); long bytesWritten = 0; ResponseCode responseCode = ResponseCode.Ok; if (IS_STATIC_CONTENT_PATH.matcher(target).matches()) { try { InputStream rawStream = getClass().getResourceAsStream(target); if (rawStream != null) { LOGGER.debug("Static content stream found for path {}", target); bytesWritten = ServletResponseFileStreamer.getInstance().streamFileToResponse(rawStream, response, HttpServletResponse.SC_OK, getContentType(contentType, target), CACHE_CONTROL_HEADER ); numOK.incrementAndGet(); } else { LOGGER.debug("Static content stream not found for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } } catch (IOException e) { ioErrorsEncountered.incrementAndGet(); LOGGER.debug("Failed to marshall static data to the output channel.", e); } catch (Exception e) { LOGGER.error("Unexpected Exception thrown processing WSDL request", e); responseCode = ResponseCode.InternalError; response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); numErrors.incrementAndGet(); } } else { LOGGER.debug("Static content stream did not match regex for path {}", target); responseCode = ResponseCode.NotFound; bytesWritten = ServletResponseFileStreamer.getInstance().stream404ToResponse(response); num404s.incrementAndGet(); } logAccess(request, response, bytesWritten, responseCode, timer); } StaticContentServiceHandler(
					String contextPath,
					String staticContentRegex,
					String contentType,
                    String uuidHeader,
                    String uuidParentsHeader,
                    GeoLocationDeserializer deserializer,
					GeoIPLocator geoIPLocator,
                    RequestLogger requestLogger,
                    boolean suppressCommasInAccessLog); @Override void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response); @ManagedAttribute @Override String getContextPath(); @ManagedAttribute long getNumOKRequests(); @ManagedAttribute long getNumErrors(); @ManagedAttribute long getNumNotFound(); @ManagedAttribute String getContentType(); void setUnknownCipherKeyLength(int unknownCipherKeyLength); @ManagedAttribute int getUnknownCipherKeyLength(); @ManagedAttribute boolean isSuppressCommasInAccessLog(); @ManagedAttribute boolean isEscapeCommasInAccessLog();  }