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.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
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

Reply via email to