On Tue, Sep 10, 2019 at 7:50 PM Simone Bordet <[email protected]> wrote:
> Hi, > > On Tue, Sep 10, 2019 at 1:41 PM John Jiang <[email protected]> > wrote: > > > > I wanted to test the HTTP/2 feature server push with Jetty 9.4.20, and > made a simple servlet like the below, > > > > public class ServerPushServlet extends HttpServlet { > > > > protected void doGet(HttpServletRequest request, > > HttpServletResponse response) throws ServletException, > IOException { > > Request req = Request.getBaseRequest(request); > > System.out.println("req: " + req); > > PushBuilder pushBuilder = req.getPushBuilder(); > > pushBuilder.path("/res").push(); > > } > > } > > > > When tried to access http://localhost:port/push with FireFox, the > following error raised, > > req: null > > 2019-09-10 16:21:58.906:WARN:oejs.HttpChannel:qtp1793329556-11: /push > > java.lang.NullPointerException > > at httptest.ServerPushServlet.push(Unknown Source) > > The problem is that > > request.getPushBuilder() > > return null if push is not supported. > > This happens because you are making the request using HTTP/1.1 as > browsers don't support HTTP/2 if it's not encrypted. > You should try https instead of http. > > I would have tried that with curl, like the below, $ curl -v --http2 http://localhost:9020/push * Trying ::1:9020... * TCP_NODELAY set * Connected to localhost (::1) port 9020 (#0) > GET /push HTTP/1.1 > Host: localhost:9020 > User-Agent: curl/7.65.3 > Accept: */* > Connection: Upgrade, HTTP2-Settings > Upgrade: h2c > HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA > * Mark bundle as not supporting multiuse < HTTP/1.1 101 Switching Protocols * Received 101 * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Connection state changed (MAX_CONCURRENT_STREAMS == 1024)! < HTTP/2 500 < cache-control: must-revalidate,no-cache,no-store < content-type: text/html;charset=iso-8859-1 < <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>Error 500 Server Error</title> </head> <body><h2>HTTP ERROR 500</h2> <p>Problem accessing /push. Reason: <pre> Server Error</pre></p><h3>Caused by:</h3><pre>java.lang.NullPointerException at httptest.ServerPushServlet.doGet(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:844) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1604) ... I think they talked HTTP/2. And I suppose this issue may not related to HTTP/2. If used HTTP/1.1, that Request still was null.
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users
