Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 23333 invoked from network); 5 Jun 2002 16:59:39 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 5 Jun 2002 16:59:39 -0000 Received: (qmail 10654 invoked by uid 97); 5 Jun 2002 16:59:41 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 10638 invoked by uid 97); 5 Jun 2002 16:59:40 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 10626 invoked by uid 98); 5 Jun 2002 16:59:40 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Message-ID: <20020605165859.7873.qmail@web21207.mail.yahoo.com> Date: Wed, 5 Jun 2002 09:58:59 -0700 (PDT) From: Jonathan Carlson Reply-To: joncrlsn@users.sf.net Subject: RE: [HttpClient] Post parameters To: Jakarta Commons Developers List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 joncrlsn@users.sf.net Minneapolis, Minnesota __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: For additional commands, e-mail: