我想在http / 2上为端口80运行一个wireshark到
scala> @transient val w = Window.partitionBy("x").orderBy("y")
w: org.apache.spark.sql.expressions.WindowSpec = org.apache.spark.sql.expressions.WindowSpec@7dda1470
scala> @transient val lag_y = lag(col("y"), 1).over(w)
lag_y: org.apache.spark.sql.Column = 'lag(y,1,null) windowspecdefinition(x,y ASC,UnspecifiedFrame)
scala> df.select(lag_y).map(f _).first
res1: String = [null]
是否有支持端口80的http / 2的网站?当我去谷歌时,总是将我改为https。
感谢, 迪恩
答案 0 :(得分:3)
Jetty项目实现了一个HTTP / 2服务器,可以使用加密的HTTP / 2和明文HTTP / 2。
您可以在本地轻松设置Jetty h2c
服务器,支持直接HTTP / 2通信,并支持HTTP / 1.1升级到HTTP / 2。
我建议您不要用实验轰炸公共服务器:)
这是服务器代码:
public class H2C
{
public static void main(String[] args) throws Exception
{
Server server = new Server();
HttpConfiguration config = new HttpConfiguration();
HttpConnectionFactory h1 = new HttpConnectionFactory(config);
HTTP2CServerConnectionFactory h2 = new HTTP2CServerConnectionFactory(config);
ServerConnector connector = new ServerConnector(server, h1, h2);
connector.setPort(8080);
server.addConnector(connector);
server.setHandler(new AbstractHandler()
{
@Override
protected void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
// Your code here.
}
});
server.start();
}
}
您可以使用HTTP / 2客户端测试服务器,例如nghttp,并通过Wireshark观察流量。
通过升级测试明文HTTP / 2(使用-u
标志,-v
标志用于详细程度):
$ nghttp -uv http://localhost:8080/
[ 0.000] Connected
[ 0.000] HTTP Upgrade request
GET / HTTP/1.1
host: localhost:8080
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.7.1
[ 0.001] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
[ 0.001] HTTP Upgrade success
[ 0.001] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
(dep_stream_id=0, weight=201, exclusive=0)
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
(dep_stream_id=0, weight=101, exclusive=0)
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
(dep_stream_id=0, weight=1, exclusive=0)
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
(dep_stream_id=7, weight=1, exclusive=0)
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
(dep_stream_id=3, weight=1, exclusive=0)
[ 0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
(dep_stream_id=11, weight=16, exclusive=0)
[ 0.001] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.002] recv (stream_id=1) :status: 200
[ 0.002] recv (stream_id=1) server: Jetty(9.4.z-SNAPSHOT)
[ 0.002] recv (stream_id=1) date: Fri, 20 May 2016 09:38:52 GMT
[ 0.002] recv HEADERS frame <length=45, flags=0x05, stream_id=1>
; END_STREAM | END_HEADERS
(padlen=0)
; First response header
[ 0.002] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
直接测试明文HTTP / 2:
$ nghttp -v http://localhost:8080/
[ 0.000] Connected
[ 0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
(dep_stream_id=0, weight=201, exclusive=0)
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
(dep_stream_id=0, weight=101, exclusive=0)
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
(dep_stream_id=0, weight=1, exclusive=0)
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
(dep_stream_id=7, weight=1, exclusive=0)
[ 0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
(dep_stream_id=3, weight=1, exclusive=0)
[ 0.000] send HEADERS frame <length=38, flags=0x25, stream_id=13>
; END_STREAM | END_HEADERS | PRIORITY
(padlen=0, dep_stream_id=11, weight=16, exclusive=0)
; Open new stream
:method: GET
:path: /
:scheme: http
:authority: localhost:8080
accept: */*
accept-encoding: gzip, deflate
user-agent: nghttp2/1.7.1
[ 0.095] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 0.095] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.096] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.105] recv (stream_id=13) :status: 200
[ 0.105] recv (stream_id=13) server: Jetty(9.4.z-SNAPSHOT)
[ 0.105] recv (stream_id=13) date: Fri, 20 May 2016 09:39:30 GMT
[ 0.105] recv HEADERS frame <length=45, flags=0x05, stream_id=13>
; END_STREAM | END_HEADERS
(padlen=0)
; First response header
[ 0.106] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])