From issues-return-2575-apmail-commons-issues-archive=commons.apache.org@commons.apache.org Sun Feb 03 19:36:30 2008 Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 67230 invoked from network); 3 Feb 2008 19:36:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Feb 2008 19:36:30 -0000 Received: (qmail 51610 invoked by uid 500); 3 Feb 2008 19:36:21 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 51538 invoked by uid 500); 3 Feb 2008 19:36:20 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 51529 invoked by uid 99); 3 Feb 2008 19:36:20 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2008 11:36:20 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2008 19:36:01 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0D5C071406E for ; Sun, 3 Feb 2008 11:36:08 -0800 (PST) Message-ID: <3818616.1202067368052.JavaMail.jira@brutus> Date: Sun, 3 Feb 2008 11:36:08 -0800 (PST) From: "Yves Zoundi (JIRA)" To: issues@commons.apache.org Subject: [jira] Resolved: (VFS-194) Redirect of HTTP url using the header location In-Reply-To: <23200830.1200921754022.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/VFS-194?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Yves Zoundi resolved VFS-194. ----------------------------- Resolution: Fixed Issue resolved with the patch > Redirect of HTTP url using the header location > ---------------------------------------------- > > Key: VFS-194 > URL: https://issues.apache.org/jira/browse/VFS-194 > Project: Commons VFS > Issue Type: Wish > Environment: Windows XP/Linux/FreeBSD > Reporter: Yves Zoundi > Attachments: svn.diff > > > The http provider classes don't test the header location before resolving a file. If the redirection is reported as invalid by commons-httpclient, then the HttpFileObject is not resolved. Here is how to fix it in all the http provider implementation classes. > int status = 0;//client.executeMethod(method); > try{ > status = client.executeMethod(method); > System.out.println("method executed"); > } > catch(Exception e){ > System.out.println("Exception co"); > try{ > HostConfiguration config = client.getHostConfiguration(); > Header header = method.getResponseHeader("Location"); > System.out.println("Checking header"); > if (header != null) { > > String redirectUrl = header.getValue(); > config.setHost(new java.net.URL(redirectUrl).getHost(), config.getPort(), config.getProtocol()); > client.setHostConfiguration(config); > status = client.executeMethod(method); > > } > } > catch(Exception err){ > throw new Exception(err); > } > > } > if ((status >= 300) && (status < 400)) { > try{ > HostConfiguration config = client.getHostConfiguration(); > Header header = method.getResponseHeader("Location"); > if (header != null) { > > String redirectUrl = header.getValue(); > method = new HeadMethod(); > setupMethod(method); > config.setHost(new java.net.URL(redirectUrl).getHost(), config.getPort(), config.getProtocol()); > client.setHostConfiguration(config); > status = client.executeMethod(method); > > } > } > catch(Exception err){ > throw new Exception(err); > } > } > method.releaseConnection(); > if (status == HttpURLConnection.HTTP_OK) > { > return FileType.FILE; > } > else if (status == HttpURLConnection.HTTP_NOT_FOUND > || status == HttpURLConnection.HTTP_GONE) > { > return FileType.IMAGINARY; > } > else > { > throw new FileSystemException("vfs.provider.http/head.error", getName()); > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.