Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.58k stars 591 forks source link

Ability to replace all headers when passing in headers map #419

Closed haroon-sheikh closed 2 years ago

haroon-sheikh commented 2 years ago

**Is your feature request related to a problem?

Currently we're able to run .headerReplace() for a single header but not a map of headers.

As part of our requests, we pass in a headers map which sometimes may include the default headers but with Unirest.get(...).headers(map), it would just append to default headers. We would like to replace the default headers if the map contains it.

Describe the solution you'd like

Unirest.get("").headersReplace(headersMap); which internally calls .headerReplace(...) for each item.

I'm happy to submit a PR if you're happy with the proposed solution.