Thanks Oleg -
Unless I'm missing something, I was thinking that it had to be something
along these lines:
/*
* Disable redirection for this one POST request
*/
RequestConfig oldConfig = context.getRequestConfig();
RequestConfig newConfig = RequestConfig.custom
().setRedirectsEnabled(false).build();
context.setRequestConfig(newConfig);
try {
response = httpClient.execute(targetHost, postMethod,
context);
} finally {
context.setRequestConfig(oldConfig);
}
>
> Well, in the worst case would this do the trick?
> ---
> class MyHttpContext implements HttpContext {
>
> private final HttpContext context;
> private RequestConfig requestConfig;
>
> public MyHttpContext(final HttpContext context) {
> super();
> this.context = Args.notNull(context, "HTTP context");
> }
>
> public Object getAttribute(final String id) {
> if (HttpClientContext.REQUEST_CONFIG.equals(id)) {
> if (this.requestConfig != null) {
> return this.requestConfig;
> } else {
> return this.context.getAttribute(id);
> }
> } else {
> return this.context.getAttribute(id);
> }
> }
>
> public Object removeAttribute(final String id) {
> if (HttpClientContext.REQUEST_CONFIG.equals(id)) {
> RequestConfig local = this.requestConfig;
> this.requestConfig = null;
> return local;
> } else {
> return this.context.removeAttribute(id);
> }
> }
>
> public void setAttribute(final String id, final Object obj) {
> if (HttpClientContext.REQUEST_CONFIG.equals(id)) {
> this.requestConfig = (RequestConfig) obj;
> } else {
> this.context.setAttribute(id, obj);
> }
> }
>
> }
> ---
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>