adam bien's blog

Debugging Incoming Headers with jwebserver 📎

jwebserver introduced with JEP 408 can be used for incoming header / user agent debugging.

Launching the web server in verbose mode with: jwebserver -o verbose, outputs the incoming headers after executing: curl http://localhost:8000:


> Accept: */*
> Host: localhost:8000
> User-agent: curl/7.79.1

The following Java HttpClient:


import java.net.http.HttpResponse.BodyHandlers;
import java.net.http.*;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("http://localhost:8000"))
                .GET()
                .build();
var response = client.send(request,BodyHandlers.ofString())

generates these headers:


> Connection: Upgrade, HTTP2-Settings
> Http2-settings: AAEAAEAAAAIAAAABAAMAAABkAAQBAAAAAAUAAEAA
> Host: localhost:8000
> User-agent: Java-http-client/19
> Upgrade: h2c

See it in action and in less than 1 min: