@Test void testService4() throws Exception { NanoPiranha piranha = new NanoPiranhaBuilder() .servlet("TestQueryStringServlet", new TestQueryStringServlet()) .build(); NanoRequest request = new NanoRequestBuilder() .method("GET") .servletPath("/index.html") .queryString("q=value") .build(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); NanoResponse response = new NanoResponseBuilder() .outputStream(outputStream) .build(); piranha.service(request, response); assertEquals("q=value", outputStream.toString()); }
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { Iterator<Filter> iterator = filters.descendingIterator(); NanoFilterChain chain = new NanoFilterChain(servlet); while (iterator.hasNext()) { Filter filter = iterator.next(); NanoFilterChain previousChain = chain; chain = new NanoFilterChain(filter, previousChain); } if (servletRequest.getServletContext() == null && servletRequest instanceof NanoRequest) { NanoRequest nanoRequest = (NanoRequest) servletRequest; nanoRequest.setWebApplication(webApplication); } if (servletResponse instanceof NanoResponse) { NanoResponse nanoResponse = (NanoResponse) servletResponse; nanoResponse.setWebApplication(webApplication); } chain.doFilter(servletRequest, servletResponse); servletResponse.flushBuffer(); }
NanoPiranha implements Piranha { public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { Iterator<Filter> iterator = filters.descendingIterator(); NanoFilterChain chain = new NanoFilterChain(servlet); while (iterator.hasNext()) { Filter filter = iterator.next(); NanoFilterChain previousChain = chain; chain = new NanoFilterChain(filter, previousChain); } if (servletRequest.getServletContext() == null && servletRequest instanceof NanoRequest) { NanoRequest nanoRequest = (NanoRequest) servletRequest; nanoRequest.setWebApplication(webApplication); } if (servletResponse instanceof NanoResponse) { NanoResponse nanoResponse = (NanoResponse) servletResponse; nanoResponse.setWebApplication(webApplication); } chain.doFilter(servletRequest, servletResponse); servletResponse.flushBuffer(); } }
NanoPiranha implements Piranha { public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { Iterator<Filter> iterator = filters.descendingIterator(); NanoFilterChain chain = new NanoFilterChain(servlet); while (iterator.hasNext()) { Filter filter = iterator.next(); NanoFilterChain previousChain = chain; chain = new NanoFilterChain(filter, previousChain); } if (servletRequest.getServletContext() == null && servletRequest instanceof NanoRequest) { NanoRequest nanoRequest = (NanoRequest) servletRequest; nanoRequest.setWebApplication(webApplication); } if (servletResponse instanceof NanoResponse) { NanoResponse nanoResponse = (NanoResponse) servletResponse; nanoResponse.setWebApplication(webApplication); } chain.doFilter(servletRequest, servletResponse); servletResponse.flushBuffer(); } NanoPiranha(); }
NanoPiranha implements Piranha { public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { Iterator<Filter> iterator = filters.descendingIterator(); NanoFilterChain chain = new NanoFilterChain(servlet); while (iterator.hasNext()) { Filter filter = iterator.next(); NanoFilterChain previousChain = chain; chain = new NanoFilterChain(filter, previousChain); } if (servletRequest.getServletContext() == null && servletRequest instanceof NanoRequest) { NanoRequest nanoRequest = (NanoRequest) servletRequest; nanoRequest.setWebApplication(webApplication); } if (servletResponse instanceof NanoResponse) { NanoResponse nanoResponse = (NanoResponse) servletResponse; nanoResponse.setWebApplication(webApplication); } chain.doFilter(servletRequest, servletResponse); servletResponse.flushBuffer(); } NanoPiranha(); void addFilter(Filter filter); List<Filter> getFilters(); Servlet getServlet(); @Override String getVersion(); WebApplication getWebApplication(); void service(ServletRequest servletRequest, ServletResponse servletResponse); void setServlet(Servlet servlet); void setWebApplication(WebApplication webApplication); }
NanoPiranha implements Piranha { public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { Iterator<Filter> iterator = filters.descendingIterator(); NanoFilterChain chain = new NanoFilterChain(servlet); while (iterator.hasNext()) { Filter filter = iterator.next(); NanoFilterChain previousChain = chain; chain = new NanoFilterChain(filter, previousChain); } if (servletRequest.getServletContext() == null && servletRequest instanceof NanoRequest) { NanoRequest nanoRequest = (NanoRequest) servletRequest; nanoRequest.setWebApplication(webApplication); } if (servletResponse instanceof NanoResponse) { NanoResponse nanoResponse = (NanoResponse) servletResponse; nanoResponse.setWebApplication(webApplication); } chain.doFilter(servletRequest, servletResponse); servletResponse.flushBuffer(); } NanoPiranha(); void addFilter(Filter filter); List<Filter> getFilters(); Servlet getServlet(); @Override String getVersion(); WebApplication getWebApplication(); void service(ServletRequest servletRequest, ServletResponse servletResponse); void setServlet(Servlet servlet); void setWebApplication(WebApplication webApplication);  }