helun/Ektorp

Setting Headers in StdHttpClient

realulim opened this issue · 2 comments

When using StdHttpClient.Builder there are a couple of methods provided to configure the http request, such as url, user, password, caching etc. However, there is no generic method to add a specific header. For example I would like to use cookie authentication with Ektorp and so I'd have to set the Cookie header.

There is a protected method configureHttpParams that is marked to be overridden, so is that the intended way to go for such cases? Or would that rather be an addition to the source code in the form of an additional builder method? Perhaps a specific one for the cookie or a generic one?

hi @realulim

Ektorp includes a builder that is able to create and configure an Apache HC (HttpClient). As I remember, it only support BASIC authentication, and it does not provide ways to configure/tune the Apache HC instance, as the original intent was to hide the fact that Ektorp uses Apache HC under the hood.

However, you can inject (a builder of) an instance of Apache HC that would be configured as you see fit.
So anything you can do with Apache HC, you could make it do by Ektorp.

I have been there a few years ago, and it worked really well.

Ok, I see what you mean. I'll take a look at that option, thank you very much.