I want to send a request without User-Agent for testing purposes. I tried to use headerRemove but it doesn't work. Is there a way to achieve this?
val request = HttpRequest.get("https://example.com")
.header("x-dummy-header", "remove me")
headerRemove("x-dummy-header")
headerRemove("User-Agent")
GET / HTTP/1.1
Connection: Close
Host: example.com
User-Agent: Jodd HTTP
Fixed in
v6.2.0(just released:). Jodd Http used to have a default User-Agent, which was set if no such header was present.Now you can do one of the two things:
HttpBase.Defaults.headers- its a map of default headers loaded in every instance ofHttpRequestHttpRequestusingheaderRemove()method or remove all default headers (there is just that one) with theheadersClean()method.