Skip to content

Setting Basic Authentication preemptive through CommonsHttpMessageSender [SWS-214] #366

@gregturn

Description

@gregturn

Mike Wiesner opened SWS-214 and commented

When using CommonsHttpMessageSender in the WebServiceTemplate to support Basic Authentication (with setCredentials()), it should also delegate the Method getParams().setAuthenticationPreemptive(true) from the underlaying HttpClient to avoid a roundtrip and to always use the actual username/password if it changes during the requests.

Currently you can do that with this code:

WebServiceTemplate template = new WebServiceTemplate();
CommonsHttpMessageSender sender = new CommonsHttpMessageSender();
sender.setCredentials(new MyCredentials());
sender.getHttpClient().getParams().setAuthenticationPreemptive(true);
sender.afterPropertiesSet();
template.setMessageSender(sender);


Affects: 1.0.1

Referenced from: commits 7e32032

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions