For example the default user agent could be set like:
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, someName);
But how to set the "Accept" header?
After installing the extension, Go to app.requestly.io/rules.Then create rule and select "Modify Headers". After that give the rule name, and from here you can add, override and remove headers by providing a Header name and value for that header.
HttpClient 4.3 now allows configuring a collection of default headers on the client itself:
Header header = new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json");
List<Header> headers = Lists.newArrayList(header);
HttpClient client = HttpClients.custom().setDefaultHeaders(headers).build();
HttpUriRequest request = RequestBuilder.get().setUri(SAMPLE_URL).build();
client.execute(request);
Now, all requests executed by that client will be send with the default headers. Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With