1

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
kamer
  • 43
  • 1
  • 7
  • 1
    Please that a look at the updated answer, had to preserve the default user agent because of the other teams, still, fixed you issue:) – igr Feb 21 '22 at 15:52

1 Answers1

1

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:

  1. Remove default headers in HttpBase.Defaults.headers - its a map of default headers loaded in every instance of HttpRequest
  2. Simply remove it from the HttpRequest using headerRemove() method or remove all default headers (there is just that one) with the headersClean() method.
igr
  • 10,199
  • 13
  • 65
  • 111