Customizable default headers in UniRest

Default Request Headers

You can set default headers that will be sent on every request:

Unirest.setDefaultHeader("Header1", "Value1");Unirest.setDefaultHeader("Header2", "Value2");

Example:

Unirest.setDefaultHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.3611");Unirest.setDefaultHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.81");Unirest.setDefaultHeader("Accept-Language", "en-GB,en-US;q=0.9,en;q=0.81");

 

You can clear the default headers anytime with:

Unirest.clearDefaultHeaders();