On Wed, 2014-10-15 at 09:50 -0400, Todd W Lainhart wrote:
> >
> > What one might do instead of cloning a context is to wrap it with a
> > decorator and discard the decorator along with all local modifications.
> >
>
> Thanks. I'll have to think on this - I'm not sure that it will solve this
> problem. The problem is that I want the HttpContext passed between
> execute(...) invocations to maintain/accumulate state for those
> invocations (e.g. cookies, redirects list) - just not inherit the
> RequestConfig state on individual requests where it's been applied.
>
> -- Todd
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]