Reputation: 20192
I would like to run a wireshark on http/2 for port 80 to
1. be able to test out an http/2 client
2. follow a wireshark trace to understand the protocol better
Is there a website that supports http/2 on port 80? When I go to google, it is always changing me to https.
thanks, Dean
Upvotes: 1
Views: 6908
Reputation: 18487
The Jetty project implements a HTTP/2 server that can work with both encrypted HTTP/2 and clear-text HTTP/2.
You can easily setup locally a Jetty h2c
server with support for direct HTTP/2 communication as well as support for HTTP/1.1 upgrade to HTTP/2.
I recommend you don't bomb a public server with your experiments :)
This is the server code:
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();
}
}
You can use a HTTP/2 client to test the server, such as nghttp, and watch the traffic via Wireshark.
Testing clear-text HTTP/2 via upgrade (using the -u
flag, the -v
flag is for verbosity):
$ 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)=[])
Or testing clear-text HTTP/2 directly:
$ 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)=[])
Upvotes: 3