@Override public void applyURI(Request request, String oldURI, String newURI) throws IOException { String uri = request.getRequestURI(); if (uri.startsWith("/")) uri = URIUtil.compactPath(uri); request.setURIPathQuery(uri); }
/** * This method will add _query to the requests's queryString and also combine it with existing queryStrings in * the request. However it won't take care for duplicate. E.g. if request.getQueryString contains a parameter * <code>param1 = true</code> and _query will contain <code>param1=false</code> the result will be <code>param1=true&param1=false</code>. * To cover this use case some more complex pattern matching is necessary. We can implement this if there's use * cases. * * @param request the request * @param oldURI the old URI * @param newURI the new URI * @throws IOException if unable to apply the URI */ @Override public void applyURI(Request request, String oldURI, String newURI) throws IOException { if (_query == null) { request.setURIPathQuery(newURI); } else { String queryString = request.getQueryString(); if (queryString != null) queryString = queryString + "&" + _query; else queryString = _query; request.setURIPathQuery(newURI); request.setQueryString(queryString); } }
@Override public void applyURI(Request request, String oldURI, String newURI) throws IOException { if (_query==null) { request.setURIPathQuery(newURI); } else { String query=(String)request.getAttribute("org.eclipse.jetty.rewrite.handler.RewriteRegexRule.Q"); if (!_queryGroup && request.getQueryString()!=null) query=request.getQueryString()+"&"+query; request.setURIPathQuery(newURI); request.setQueryString(query); } }
@Override public void doHandle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { final String newTarget = redirectContext + target; RequestUpdateHandler.ForwardedRequest newRequest = new RequestUpdateHandler.ForwardedRequest( request, redirectContext, newTarget); // if the request already has the /{gatewaypath}/{topology} part then skip if (!StringUtils.startsWithIgnoreCase(target, redirectContext)) { baseRequest.setPathInfo(redirectContext + baseRequest.getPathInfo()); baseRequest.setURIPathQuery(redirectContext + baseRequest.getRequestURI()); LOG.topologyPortMappingUpdateRequest(target, newTarget); nextHandle(newTarget, baseRequest, newRequest, response); } else { nextHandle(target, baseRequest, newRequest, response); } }
@Override public void doHandle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { final String newTarget = redirectContext + target; RequestUpdateHandler.ForwardedRequest newRequest = new RequestUpdateHandler.ForwardedRequest( request, redirectContext, newTarget); // if the request already has the /{gatewaypath}/{topology} part then skip if (!StringUtils.startsWithIgnoreCase(target, redirectContext)) { baseRequest.setPathInfo(redirectContext + baseRequest.getPathInfo()); baseRequest.setURIPathQuery(redirectContext + baseRequest.getRequestURI()); LOG.topologyPortMappingUpdateRequest(target, newTarget); nextHandle(newTarget, baseRequest, newRequest, response); } else { nextHandle(target, baseRequest, newRequest, response); } }
((Rule.ApplyURI)rule).applyURI(baseRequest, baseRequest.getRequestURI(), encoded); else baseRequest.setURIPathQuery(encoded);
public void handleAsync(HttpChannel channel) throws IOException, ServletException { final HttpChannelState state = channel.getRequest().getHttpChannelState(); final AsyncContextEvent event = state.getAsyncContextEvent(); final Request baseRequest=channel.getRequest(); final String path=event.getPath(); if (path!=null) { // this is a dispatch with a path ServletContext context=event.getServletContext(); String query=baseRequest.getQueryString(); baseRequest.setURIPathQuery(URIUtil.addEncodedPaths(context==null?null:URIUtil.encodePath(context.getContextPath()), path)); HttpURI uri = baseRequest.getHttpURI(); baseRequest.setPathInfo(uri.getDecodedPath()); if (uri.getQuery()!=null) baseRequest.mergeQueryParameters(query,uri.getQuery(), true); //we have to assume dispatch path and query are UTF8 } final String target=baseRequest.getPathInfo(); final HttpServletRequest request=(HttpServletRequest)event.getSuppliedRequest(); final HttpServletResponse response=(HttpServletResponse)event.getSuppliedResponse(); if (LOG.isDebugEnabled()) LOG.debug("{} {} {} on {}", request.getDispatcherType(), request.getMethod(), target, channel); handle(target, baseRequest, request, response); if (LOG.isDebugEnabled()) LOG.debug("handledAsync={} async={} committed={} on {}", channel.getRequest().isHandled(),request.isAsyncStarted(),response.isCommitted(),channel); }
public void handleAsync(HttpChannel connection) throws IOException, ServletException { final HttpChannelState state = connection.getRequest().getHttpChannelState(); final AsyncContextEvent event = state.getAsyncContextEvent(); final Request baseRequest=connection.getRequest(); final String path=event.getPath(); if (path!=null) { // this is a dispatch with a path ServletContext context=event.getServletContext(); String query=baseRequest.getQueryString(); baseRequest.setURIPathQuery(URIUtil.addPaths(context==null?null:context.getContextPath(), path)); HttpURI uri = baseRequest.getHttpURI(); baseRequest.setPathInfo(uri.getDecodedPath()); if (uri.getQuery()!=null) baseRequest.mergeQueryParameters(query,uri.getQuery(), true); //we have to assume dispatch path and query are UTF8 } final String target=baseRequest.getPathInfo(); final HttpServletRequest request=(HttpServletRequest)event.getSuppliedRequest(); final HttpServletResponse response=(HttpServletResponse)event.getSuppliedResponse(); if (LOG.isDebugEnabled()) { LOG.debug(request.getDispatcherType()+" "+request.getMethod()+" "+target+" on "+connection); handle(target, baseRequest, request, response); LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()); } else handle(target, baseRequest, request, response); }