Search in sources :

Example 1 with UrlRewriteResponse

use of org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteResponse in project knox by apache.

the class UrlRewriteServletFilter method doFilter.

@Override
protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
    FilterConfig config = getConfig();
    UrlRewriteRequest rewriteRequest = new UrlRewriteRequest(config, request);
    UrlRewriteResponse rewriteResponse = new UrlRewriteResponse(config, rewriteRequest, response);
    chain.doFilter(rewriteRequest, rewriteResponse);
}
Also used : UrlRewriteRequest(org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteRequest) FilterConfig(javax.servlet.FilterConfig) UrlRewriteResponse(org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteResponse)

Example 2 with UrlRewriteResponse

use of org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteResponse in project knox by apache.

the class InboundUrlFunctionProcessorTest method getRewriteResponse.

private UrlRewriteResponse getRewriteResponse() throws Exception {
    UrlRewriteProcessor rewriter = EasyMock.createNiceMock(UrlRewriteProcessor.class);
    EasyMock.expect(rewriter.getConfig()).andReturn(null).anyTimes();
    ServletContext context = EasyMock.createNiceMock(ServletContext.class);
    EasyMock.expect(context.getAttribute(UrlRewriteServletContextListener.PROCESSOR_ATTRIBUTE_NAME)).andReturn(rewriter).anyTimes();
    FilterConfig config = EasyMock.createNiceMock(FilterConfig.class);
    EasyMock.expect(config.getInitParameter(UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM)).andReturn("test-filter").anyTimes();
    EasyMock.expect(config.getServletContext()).andReturn(context).anyTimes();
    HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
    EasyMock.expect(request.getParameterValues("host")).andReturn(new String[] { "http://foo:50075" }).anyTimes();
    HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
    EasyMock.replay(rewriter, context, config, request, response);
    return new UrlRewriteResponse(config, request, response);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) UrlRewriteProcessor(org.apache.knox.gateway.filter.rewrite.api.UrlRewriteProcessor) ServletContext(javax.servlet.ServletContext) HttpServletResponse(javax.servlet.http.HttpServletResponse) FilterConfig(javax.servlet.FilterConfig) UrlRewriteResponse(org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteResponse)

Aggregations

FilterConfig (javax.servlet.FilterConfig)2 UrlRewriteResponse (org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteResponse)2 ServletContext (javax.servlet.ServletContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 UrlRewriteProcessor (org.apache.knox.gateway.filter.rewrite.api.UrlRewriteProcessor)1 UrlRewriteRequest (org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteRequest)1