@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)
				|| monitoringDisabled || !instanceEnabled) {
			// si ce n'est pas une requête http ou si le monitoring est désactivé, on fait suivre
			chain.doFilter(request, response);
			return;
		}
		final HttpServletRequest httpRequest = (HttpServletRequest) request;
		final HttpServletResponse httpResponse = (HttpServletResponse) response;

		if (httpRequest.getRequestURI().equals(getMonitoringUrl(httpRequest))) {
			doMonitoring(httpRequest, httpResponse);
			return;
		}
		if (!httpCounter.isDisplayed() || isRequestExcluded((HttpServletRequest) request)) {
			// si cette url est exclue ou si le counter http est désactivé, on ne monitore pas cette requête http
			chain.doFilter(request, response);
			return;
		}

		doFilter(chain, httpRequest, httpResponse);
	}
@Test
	public void testDoFilterWithGWT() throws ServletException, IOException {
		final HttpServletRequest request = createNiceMock(HttpServletRequest.class);
		final String textGwtRpc = "text/x-gwt-rpc";
		expect(request.getContentType()).andReturn(textGwtRpc).anyTimes();
		expect(request.getInputStream())
				.andReturn(createInputStreamForString("1|2|3|4|5|6|7|8|9|10")).anyTimes();
		doFilter(request);

		final HttpServletRequest request2a = createNiceMock(HttpServletRequest.class);
		expect(request2a.getContentType()).andReturn("not/x-gwt-rpc").anyTimes();
		expect(request2a.getInputStream())
				.andReturn(createInputStreamForString("1|2|3|4|5|6|7|8|9|10")).anyTimes();
		doFilter(request2a);

		final HttpServletRequest request2b = createNiceMock(HttpServletRequest.class);
		expect(request2b.getContentType()).andReturn(textGwtRpc).anyTimes();
		expect(request2b.getInputStream()).andReturn(createInputStreamForString("1|2|3|4|5|6"))
				.anyTimes();
		expect(request2b.getReader()).andReturn(new BufferedReader(new StringReader("1|2|3|4|5|6")))
				.anyTimes();
		replay(request2b);
		final PayloadNameRequestWrapper wrapper2b = new PayloadNameRequestWrapper(request2b);
		wrapper2b.getInputStream().read();
		wrapper2b.getReader().read();
		verify(request2b);

		final HttpServletRequest request2 = createNiceMock(HttpServletRequest.class);
		expect(request2.getContentType()).andReturn(textGwtRpc).anyTimes();
		expect(request2.getInputStream())
				.andReturn(createInputStreamForString("1|2|3|4|5|6||8|9|10")).anyTimes();
		expect(request2.getReader()).andReturn(new BufferedReader(new StringReader("1|2|3|4|5|6")))
				.anyTimes();
		replay(request2);
		final PayloadNameRequestWrapper wrapper2 = new PayloadNameRequestWrapper(request2);
		wrapper2.getInputStream().read();
		wrapper2.getReader().read();
		verify(request2);

		final HttpServletRequest request3 = createNiceMock(HttpServletRequest.class);
		expect(request3.getContentType()).andReturn(textGwtRpc).anyTimes();
		expect(request3.getCharacterEncoding()).andReturn("utf-8").anyTimes();
		expect(request3.getInputStream())
				.andReturn(createInputStreamForString("1|2|3|4|5|6||8|9|10")).anyTimes();
		expect(request3.getReader()).andReturn(new BufferedReader(new StringReader("1|2|3|4|5|6")))
				.anyTimes();
		replay(request3);
		final PayloadNameRequestWrapper wrapper3 = new PayloadNameRequestWrapper(request3);
		wrapper3.getInputStream().read();
		wrapper3.getInputStream().read();
		wrapper3.getReader().read();
		wrapper3.getReader().read();
		verify(request3);
	}