@Test public void testFilterNoQueries() throws IOException, ServletException { filter.doFilter(requestWithPathAndQueryParameter, httpServletResponse, filterChain); assertEquals(0, httpServletResponse.getHeaderValue(HEADER_NUMBER_OF_QUERIES)); }
public void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException { Object existingRequestProcessorAttribute = request.getAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); if (null != existingRequestProcessorAttribute) { chain.doFilter(request, response); return; } HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!isSniffyFilterEnabled(request, httpServletRequest, httpServletResponse)) { chain.doFilter(request, response); return; } if (ConnectionsRegistry.INSTANCE.isThreadLocal()) { copyFaultToleranceTestingFromSession((HttpServletRequest) request); } if (null != sniffyServlet) { try { sniffyServlet.service(request, response); if (response.isCommitted()) return; } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyServlet; calling original chain", e); chain.doFilter(request, response); return; } } SniffyRequestProcessor sniffyRequestProcessor; try { sniffyRequestProcessor = new SniffyRequestProcessor(this, httpServletRequest, httpServletResponse); request.setAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME, sniffyRequestProcessor); } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyRequestProcessor initialization; calling original chain", e); chain.doFilter(request, response); return; } try { sniffyRequestProcessor.process(chain); } finally { request.removeAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); cleanThreadLocalFaultToleranceSettings(); } }
SniffyFilter implements Filter { public void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException { Object existingRequestProcessorAttribute = request.getAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); if (null != existingRequestProcessorAttribute) { chain.doFilter(request, response); return; } HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!isSniffyFilterEnabled(request, httpServletRequest, httpServletResponse)) { chain.doFilter(request, response); return; } if (ConnectionsRegistry.INSTANCE.isThreadLocal()) { copyFaultToleranceTestingFromSession((HttpServletRequest) request); } if (null != sniffyServlet) { try { sniffyServlet.service(request, response); if (response.isCommitted()) return; } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyServlet; calling original chain", e); chain.doFilter(request, response); return; } } SniffyRequestProcessor sniffyRequestProcessor; try { sniffyRequestProcessor = new SniffyRequestProcessor(this, httpServletRequest, httpServletResponse); request.setAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME, sniffyRequestProcessor); } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyRequestProcessor initialization; calling original chain", e); chain.doFilter(request, response); return; } try { sniffyRequestProcessor.process(chain); } finally { request.removeAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); cleanThreadLocalFaultToleranceSettings(); } } }
SniffyFilter implements Filter { public void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException { Object existingRequestProcessorAttribute = request.getAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); if (null != existingRequestProcessorAttribute) { chain.doFilter(request, response); return; } HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!isSniffyFilterEnabled(request, httpServletRequest, httpServletResponse)) { chain.doFilter(request, response); return; } if (ConnectionsRegistry.INSTANCE.isThreadLocal()) { copyFaultToleranceTestingFromSession((HttpServletRequest) request); } if (null != sniffyServlet) { try { sniffyServlet.service(request, response); if (response.isCommitted()) return; } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyServlet; calling original chain", e); chain.doFilter(request, response); return; } } SniffyRequestProcessor sniffyRequestProcessor; try { sniffyRequestProcessor = new SniffyRequestProcessor(this, httpServletRequest, httpServletResponse); request.setAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME, sniffyRequestProcessor); } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyRequestProcessor initialization; calling original chain", e); chain.doFilter(request, response); return; } try { sniffyRequestProcessor.process(chain); } finally { request.removeAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); cleanThreadLocalFaultToleranceSettings(); } } SniffyFilter(); }
SniffyFilter implements Filter { public void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException { Object existingRequestProcessorAttribute = request.getAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); if (null != existingRequestProcessorAttribute) { chain.doFilter(request, response); return; } HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!isSniffyFilterEnabled(request, httpServletRequest, httpServletResponse)) { chain.doFilter(request, response); return; } if (ConnectionsRegistry.INSTANCE.isThreadLocal()) { copyFaultToleranceTestingFromSession((HttpServletRequest) request); } if (null != sniffyServlet) { try { sniffyServlet.service(request, response); if (response.isCommitted()) return; } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyServlet; calling original chain", e); chain.doFilter(request, response); return; } } SniffyRequestProcessor sniffyRequestProcessor; try { sniffyRequestProcessor = new SniffyRequestProcessor(this, httpServletRequest, httpServletResponse); request.setAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME, sniffyRequestProcessor); } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyRequestProcessor initialization; calling original chain", e); chain.doFilter(request, response); return; } try { sniffyRequestProcessor.process(chain); } finally { request.removeAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); cleanThreadLocalFaultToleranceSettings(); } } SniffyFilter(); void init(FilterConfig filterConfig); void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain); void destroy(); boolean isInjectHtml(); void setInjectHtml(boolean injectHtml); Pattern getInjectHtmlExcludePattern(); void setInjectHtmlExcludePattern(Pattern injectHtmlExcludePattern); @Deprecated boolean isEnabled(); @Deprecated void setEnabled(boolean enabled); boolean isFilterEnabled(); void setFilterEnabled(boolean filterEnabled); boolean isMonitorSocket(); void setMonitorSocket(boolean monitorSocket); Pattern getExcludePattern(); void setExcludePattern(Pattern excludePattern); }
SniffyFilter implements Filter { public void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain) throws IOException, ServletException { Object existingRequestProcessorAttribute = request.getAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); if (null != existingRequestProcessorAttribute) { chain.doFilter(request, response); return; } HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; if (!isSniffyFilterEnabled(request, httpServletRequest, httpServletResponse)) { chain.doFilter(request, response); return; } if (ConnectionsRegistry.INSTANCE.isThreadLocal()) { copyFaultToleranceTestingFromSession((HttpServletRequest) request); } if (null != sniffyServlet) { try { sniffyServlet.service(request, response); if (response.isCommitted()) return; } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyServlet; calling original chain", e); chain.doFilter(request, response); return; } } SniffyRequestProcessor sniffyRequestProcessor; try { sniffyRequestProcessor = new SniffyRequestProcessor(this, httpServletRequest, httpServletResponse); request.setAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME, sniffyRequestProcessor); } catch (Exception e) { if (null != servletContext) servletContext.log("Exception in SniffyRequestProcessor initialization; calling original chain", e); chain.doFilter(request, response); return; } try { sniffyRequestProcessor.process(chain); } finally { request.removeAttribute(SNIFFY_REQUEST_PROCESSOR_REQUEST_ATTRIBUTE_NAME); cleanThreadLocalFaultToleranceSettings(); } } SniffyFilter(); void init(FilterConfig filterConfig); void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain); void destroy(); boolean isInjectHtml(); void setInjectHtml(boolean injectHtml); Pattern getInjectHtmlExcludePattern(); void setInjectHtmlExcludePattern(Pattern injectHtmlExcludePattern); @Deprecated boolean isEnabled(); @Deprecated void setEnabled(boolean enabled); boolean isFilterEnabled(); void setFilterEnabled(boolean filterEnabled); boolean isMonitorSocket(); void setMonitorSocket(boolean monitorSocket); Pattern getExcludePattern(); void setExcludePattern(Pattern excludePattern); static final String HEADER_CORS_HEADERS; static final String HEADER_NUMBER_OF_QUERIES; static final String HEADER_TIME_TO_FIRST_BYTE; static final String HEADER_REQUEST_DETAILS; static final String SNIFFY_URI_PREFIX; static final String JAVASCRIPT_URI; static final String JAVASCRIPT_SOURCE_URI; static final String JAVASCRIPT_MAP_URI; static final String REQUEST_URI_PREFIX; static final String SNIFFY; static final String SNIFFY_ENABLED_PARAMETER; static final String INJECT_HTML_ENABLED_PARAMETER; }