The HostHeaderFilter in CliOperationRequest is meant to elide only an implicit Host header, but its allow(String name, List<String> value) implementation never inspects the header name:
@Override
public boolean allow(String name, List<String> value) {
return !(value.isEmpty() || this.getImplicitHostHeader().equals(value.get(0)));
}
The filter is applied to every header, so any header whose first value happens to equal the host (or host:port) of the request URI is silently removed from the generated curl and http commands. For example, on a request to http://localhost/foo, a header X-Forwarded-Host: localhost disappears from the documented commands. A header with an empty value list is also dropped.
Reproduced on main (3ec9c63, 4.0.2-SNAPSHOT) with a CurlRequestSnippetTests case:
expected: "$ curl 'http://localhost/foo' -i -X GET -H 'X-Forwarded-Host: localhost'"
but was: "$ curl 'http://localhost/foo' -i -X GET"
Expected: only the Host header is subject to the implicit-host elision; all other headers appear in the snippet regardless of their value. I will submit a PR with a fix and test.
The
HostHeaderFilterinCliOperationRequestis meant to elide only an implicitHostheader, but itsallow(String name, List<String> value)implementation never inspects the header name:The filter is applied to every header, so any header whose first value happens to equal the
host(orhost:port) of the request URI is silently removed from the generatedcurlandhttpcommands. For example, on a request tohttp://localhost/foo, a headerX-Forwarded-Host: localhostdisappears from the documented commands. A header with an empty value list is also dropped.Reproduced on
main(3ec9c63, 4.0.2-SNAPSHOT) with aCurlRequestSnippetTestscase:Expected: only the
Hostheader is subject to the implicit-host elision; all other headers appear in the snippet regardless of their value. I will submit a PR with a fix and test.