[ https://issues.apache.org/jira/browse/HTTPCLIENT-2342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17883231#comment-17883231 ]
Arturo Bernal commented on HTTPCLIENT-2342: ------------------------------------------- Hi [~ctabin] I ran a test with {{HttpClient 5.4}} and was able to observe the {{Content-Type}} header being returned correctly in the response, as demonstrated by the following example: {code:java} Accept-Ranges: bytes Age: 61964 Cache-Control: max-age=604800 Content-Type: text/html; charset=UTF-8 Date: Fri, 20 Sep 2024 11:54:59 GMT Etag: "3147526947" Expires: Fri, 27 Sep 2024 11:54:59 GMT Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT Server: ECAcc (dcd/7D24) Vary: Accept-Encoding X-Cache: HIT {code} {code:java} try (CloseableHttpClient httpClient = HttpClients.createDefault()) { final HttpGet request = new HttpGet("https://example.com"); try (CloseableHttpResponse response = httpClient.execute(request)) { for (final Header header : response.getHeaders()) { System.out.println(header.getName() + ": " + header.getValue()); } final Header contentType = response.getFirstHeader("Content-Type"); if (contentType != null) { System.out.println("Content-Type found: " + contentType.getValue()); } else { System.out.println("Content-Type header is missing!"); } } } }{code} > Regression: Content-Type header not returned anymore > ---------------------------------------------------- > > Key: HTTPCLIENT-2342 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2342 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient (classic) > Affects Versions: 5.4-beta1 > Reporter: Cedric Tabin > Priority: Major > > Hello, > We just upgraded today to httpclient5 version 5.4. It seems that the header > `Content-Type` is not returned anymore by the API, even when listing all the > headers. > {code:java} > client.execute(httpRequest, r -> { > //does not print Content-Type header > for(Header h : r.getHeaders()) { > System.out.println("## "+h.getName()+": "+h.getValue()); > } > System.out.flush(); > return null; > }); > {code} > We can ensure that the `Content-Type` header is well set by the server by > browsing to the same URL and inspecting the network. > Our code didn't change and with the version 5.3.1, the Content-Type is > correctly received. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org