【发布时间】:2017-10-29 20:06:44
【问题描述】:
我正在试验 HTTP/2。我在this repo 中找到了一些示例。这是构造函数(跳过样板代码):
public WebServer(String path, HttpServlet servlet, int port) {
Server server = new Server(new QueuedThreadPool());
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
context.addServlet(new ServletHolder(servlet), path);
ServerConnector connector = new ServerConnector(server, 1,1, new HTTP2ServerConnectionFactory(new HttpConfiguration()));
connector.setPort(port);
server.addConnector(connector);
}
然后我start()服务器,从上面提到的repo运行java http2客户端,它连接没有错误。但后来我尝试对 curl 做同样的事情:
# curl --http2 http://localhost:8080
invalid_preface
浏览器(Chrome)说:
GET http://localhost:8080/ net::ERR_INVALID_HTTP_RESPONSE
服务器怎么了?
【问题讨论】: