I have a server which replies first with status code 103 ( and some headers) and then with 200 ( plus some other headers) curl -I
output below:
HTTP/2 103
link: <https://cdn.shopify.com>; rel=preconnect, <https://cdn.shopify.com>; crossorigin; rel=preconnect
HTTP/2 200
date: Mon, 08 Aug 2022 10:28:30 GMT content-type: text/html; charset=utf-8 x-sorting-hat-podid: 236 x-sorting-hat-shopid: 366627 x-storefront-renderer-rendered: 1 set-cookie: secure_customer_sig=;
My java.net.http.HttpClient seems to detect only the first status code (103) and reads only the first headers.
HttpClient httpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.followRedirects(HttpClient.Redirect.NORMAL)
.connectTimeout(Duration.ofMinutes(1))
.build();
HttpRequest request = HttpRequest
.newBuilder(httpReq, (name, value) -> true)
.header("user-agent", "Mozilla/5.0 (X11....")
//other headers here
.build();
HttpResponse<InputStream> response = httpClient.send(
request,
HttpResponse.BodyHandlers.ofInputStream()
);
logger.debug("call returned status code {}", response.statusCode());
The code above only shows 103 as status code ( which is an intermediary status code as you saw in the output of curl). How do I skip that status code + its headers ? I'm only interested in the final (200) status code and the subsequent headers.