On Thu, Sep 12, 2019 at 3:41 AM Simone Bordet <sbor...@webtide.com> wrote:
> Hi, > > On Wed, Sep 11, 2019 at 4:35 AM John Jiang <john.sha.ji...@gmail.com> > wrote: > > Yes, curl tool doesn't support server push yet, even though libcurl > supports that. > > But as I mentioned in my last reply, this failure may not be related to > server push or HTTP/2. > > That servlet didn't get the instance of org.eclipse.jetty.server.Request. > > It didn't touch org.eclipse.jetty.server.PushBuilder yet. > > > > For clarification, please consider the below simple servlet, > > package test; > > > > import java.io.IOException; > > import javax.servlet.ServletException; > > import javax.servlet.http.HttpServlet; > > import javax.servlet.http.HttpServletRequest; > > import javax.servlet.http.HttpServletResponse; > > import org.eclipse.jetty.server.Request; > > > > public class TestServlet extends HttpServlet { > > > > private static final long serialVersionUID = 5222793251610509039L; > > > > @Override > > public void doGet(HttpServletRequest request, HttpServletResponse > response) > > throws ServletException, IOException { > > if(Request.getBaseRequest(request) == null) { > > throw new RuntimeException( > > "Cannot get org.eclipse.jetty.server.Request > instance"); > > } > > } > > } > > Server implementation classes are hidden to web applications per the > Servlet Specification. > You cannot cast HttpServletRequest to a Jetty request IFF you are > deploying your web application to a standalone server. > It would be possible if you use Jetty embedded and no *.war, since > there are no webapp classloaders. > I also suspected this point. Some of Jetty built-in servlets/filters, e.g PushCacheFilter, in jetty-servlets jar also call Request.getBaseRequest(request), and have no this problem. They are registered to org.eclipse.jetty.webapp.WebAppContext. > > It's wrong to put jetty-server.jar into WEB-INF/lib. > Even if the code above compiles, the Request class will be the one > from the webapp classloader and not from the server, and that's why > you get null (instanceof checks fails). > > You have these choices: > 1. Write an embedded Jetty application, no war, everything in a single > classloader and you're good: Request will be accessible and you can > use the push API. > 2. Use Jetty 10.0.0-alpha0 (pretty stable already) which uses Servlet > 4.0 so you can use the standard API > I would try this way. Thanks!
_______________________________________________ jetty-users mailing list jetty-users@eclipse.org To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users