Hi Marc,
You asked for suggestions. As I said in my previous note,
chaining to other instances of HttpMethod would probably
help improve the readability and maintainability of the
HttpMethodBase class.
Here are more specifics on the implementation I would
suggest:
1) Have an ivar defined something like:
private HttpMethod redirectedTo = null;
2) Instead of looping inside #execute to handle redirects,
populate the "redirectedTo" ivar with a new HttpMethod
impl with the results of a new HttpMethod method like
this pseudocode:
GetMethod implementation:
public HttpMethod createRedirectMethod(String path) {
GetMethod gm = new GetMethod(path);
// assuming requestHeaders can be made protected
gm.requestHeaders = this.requestHeaders;
return gm;
}
PostMethod implementation:
public HttpMethod createRedirectMethod(String path) {
if (useOfficialRedirectSpec) {
PostMethod pm = new PostMethod(path);
pm.requestHeaders = this.requestHeaders;
pm.parameters = this.parameters;
return pm;
} else {
GetMethod gm = new GetMethod(path);
gm.requestHeaders = this.requestHeaders;
return gm;
}
}
This will do several things:
a) Keep knowledge of subclasses out of the abstract
HttpMethodBase.
b) Avoid adding any more if statements to #execute.
c) Allow for other subclasses that can define their
own behavior without modifying the superclass.
3) Change the get methods (like #getResponseBody and
#getResponseCode) to forward the request to the
"redirectedTo" instance if it's not null. Otherwise
return your own values. This will allow for cleaner
handling of multiple redirects and fewer bugs.
Jonathan
=====
Jonathan Carlson
[EMAIL PROTECTED]
Minneapolis, Minnesota
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>