Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 24287 invoked from network); 7 May 2002 14:08:20 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 7 May 2002 14:08:20 -0000 Received: (qmail 17434 invoked by uid 97); 7 May 2002 14:07:51 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 17344 invoked by uid 97); 7 May 2002 14:07:49 -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 17311 invoked by uid 98); 7 May 2002 14:07:48 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Message-ID: From: Marc.Saegesser@apropos.com To: commons-dev@jakarta.apache.org Subject: RE: [httpclient]: Q about HttpMultiClient and redirects Date: Tue, 7 May 2002 09:10:58 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Yep, I need to fix this and its actually next on my list. There are some other problems with this code. Namely, we really can't deal with all 303 responses *inside* HttpClient or HttpMultiClient, it may have to pass the 303 response back to the caller in order to do the right thing. The 303 response indicates that the client should use a GET request for the new location instead of using the same method as the original request. Note that most browsers currently get this wrong and always send a GET in response to a 302 result. Yahoo! event *requires* that the client violate the HTTP specification and send a GET in response to a 302 redirect of a POST method in order to get logged in. Neither HttpClient nor HttpMultiClient have the ability to change the method because the 'method' is actually a Java object that got passed in to the executeMethod() method. So, if we get a 303 result in response to anything besides a GET method we have no choice but to send the 303 result back to the caller and have them generate a new GET request for the new location. This sucks, but given the current architecture I don't see any way around it. To deal with Yahoo! we have to pass back the 405 Method Not Allowed response and have the caller guess that it should send back a GET instead of the POST. Againk this sucks, but I don't see any other alternative right now. Marc Saegesser > -----Original Message----- > From: otisg [mailto:otisg@iVillage.com] > Sent: Monday, May 06, 2002 5:54 PM > To: commons-dev@jakarta.apache.org > Subject: [httpclient]: Q about HttpMultiClient and redirects > > > Hello, > > Is there a way to 'catch' redirected URLs when using HttpMultiClient? > It seems like this block of code, which is a part of executeMethod > method, always gets executed if the status code matches. > Wouldn't it be useful to have a setFollowRedirects(boolean) method in > HttpMultiClient, as well as a matching getFollowRedirects() > method? If I > were to use HttpMultiClient, and I'd like to, I would need > this, since I > need to differentiate between URLs that return a 200 OK, and > one of the > resource moved codes. > > if (status == 301 || status == 302 || > status == 303 || status == 307) > { > Header header = method.getResponseHeader("Location"); > String url = header.getValue(); > if (url == null) > { > log.error("HttpMultiClient.executeMethod: Received redirect without > Location header."); > throw new HttpException("Received redirect without Location header."); > } > > method.recycle(); > method.setUrl(url); > return executeMethod(method); > } > > I can provide patch....just let me know, since I can't commit to > commons. > > Thanks, > Otis > _______________________________________________________________ > Sign up for FREE iVillage newsletters > . > From health and pregnancy to shopping and relationships, iVillage > has the scoop on what matters most to you. > -- To unsubscribe, e-mail: For additional commands, e-mail: