hi,I found a class org.eclipse.jetty.server.Request<http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/Request.html>,that can get the specified header.
And I wrote these codes to jetty-rewirte.xml, call you tell me how to correct these codes? *<Configure>* * <!-- rewrite by header options -->* * <Call name="addRule">* * <Arg>* * <New id="request" class="org.eclipse.jetty.server.Request" />* * <New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">* * <Set name="regex">^/(.*)$</Set>* * <Set name="replacement">/<Ref id="request" ><Get name="header"><Arg>Hash</Arg></Get></Ref>/$1</Set>* * </New>* * </Arg>* * </Call>* *</Configure>* Thank you! On Sun, Aug 7, 2011 at 10:07 AM, zhiwei chen <[email protected]> wrote: > Thank you, Andrea. > > This specified header is sent by nginx, I have many apps, and I want to do > this on jetty server, is there another way to do this? > > > On Sat, Aug 6, 2011 at 7:36 PM, Andrea Sodomaco <[email protected]>wrote: > >> Hi, >> why don't you use a fIlter? >> Something like >> >> public class HashFilter implements Filter { >> >> >> public void doFilter(ServletRequest request, ServletResponse >> response, >> FilterChain nextFilter) >> throws ServletException, IOException >> { >> >> request.setAttribute("caucho.form.character.encoding","UTF-8"); >> HttpServletRequest req = (HttpServletRequest) request; >> HttpServletResponse res = (HttpServletResponse) response; >> >> String hash=req.getHeader("Hash"); >> if (hash!=null) >> >> request.getRequestDispatcher("/"+hash+req.getRequestURI()).forward(req, >> res); >> >> nextFilter.doFilter(request, response); >> } >> } >> >> >> in web.xml >> >> <filter> >> <filter-name>hashFilter</filter-name> >> <filter-class>com.package.HashFilter</filter-class> >> </filter> >> >> <filter-mapping> >> <filter-name>hashFilter</filter-name> >> <url-pattern>/*</url-pattern> >> </filter-mapping> >> >> >> bye >> Andrea >> >> >> >> On 6/08/11 1:14 PM, zhiwei chen wrote: >> >> hi,all. >> I give the specified request header to jetty server,how can I get this >> specified field and add it to the URI? >> >> For example: >> Request header: >> >> *GET /hello/test.txt HTTP/1.1* >> *User-Agent: curl/7.21.3* >> *Host: localhost* >> *Accept: */** >> *Hash:234* >> * >> * >> As you can see,this request header has a specified field "Hash",the URI is >> "/hello/test.txt". >> >> I want to rewrite this URI to "/234/hello/test.txt"(i.e.: the new URI is >> : /Hash/oldURI ) >> >> I googled the sites,and find this page( >> http://api.dpml.net/org/mortbay/jetty/6.1.0/org/mortbay/jetty/Request.html#getHeader(java.lang.String) >> ) >> Jetty7 hasn't this class,so how should I get the specified request header >> field and rewrite the request URI? >> >> Is jetty-rewirte.xml can do this? How to add this rule? >> >> Thank you! >> >> >> _______________________________________________ >> jetty-users mailing >> [email protected]https://dev.eclipse.org/mailman/listinfo/jetty-users >> >> >> >> _______________________________________________ >> jetty-users mailing list >> [email protected] >> https://dev.eclipse.org/mailman/listinfo/jetty-users >> >> >
_______________________________________________ jetty-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/jetty-users
