Return-Path: Delivered-To: apmail-hc-dev-archive@www.apache.org Received: (qmail 18211 invoked from network); 2 Mar 2011 23:09:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Mar 2011 23:09:58 -0000 Received: (qmail 21280 invoked by uid 500); 2 Mar 2011 23:09:57 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 21247 invoked by uid 500); 2 Mar 2011 23:09:57 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 21239 invoked by uid 99); 2 Mar 2011 23:09:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2011 23:09:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Mar 2011 23:09:57 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 2AA274C50E for ; Wed, 2 Mar 2011 23:09:37 +0000 (UTC) Date: Wed, 2 Mar 2011 23:09:37 +0000 (UTC) From: "Angus Ng (JIRA)" To: dev@hc.apache.org Message-ID: <266268720.9425.1299107377171.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Commented: (HTTPCLIENT-929) Request with two forward slashes for path fails MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCLIENT-929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13001748#comment-13001748 ] Angus Ng commented on HTTPCLIENT-929: ------------------------------------- I am using httpclient 4.1. I had a problem with this fix. In DefaultRequestDirector.rewriteRequestURI method, for non-proxied URI and when it is a absolute URI, it will call the URIUtils.rewriteURI, which then take the "RawPath" from an uri and normalize it. So when I pass an uri, for example, http://www.whatever.com/1//3, it will automatically remove the extra slash and become http://www.whatever.com/1/3. I've got a REStful service to accept the uri (/{param1}/{param2}/{param3}) and it takes when there is an empty value past in. Now because of the auto slash removal, the "3" value shift left for a position and match to the {param2}. I wouldn't say the above solution is wrong, but I guess it should not change what value that user pass in. > Request with two forward slashes for path fails > ----------------------------------------------- > > Key: HTTPCLIENT-929 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-929 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient > Affects Versions: 4.0.1 > Reporter: Ryan Stewart > Fix For: 4.1 Alpha2 > > > The following code demonstrates the problem: > DefaultHttpClient client = new DefaultHttpClient(); > client.execute(new HttpGet("http://www.google.com//")); > When a request is made, the DefaultRequestDirector invokes rewriteRequestURI(). I don't fully understand why this method does what it does. For a non-proxied request, it attempts to render the URI to a relative URI. In doing so, it tries to create a relative URI whose content is "//". Per RFC 2396 section 5 (Relative URI References), a relative URI that begins with "//" is a network-path reference, and the "//" must be immediately followed by an authority. Therefore, while "http://www.google.com//" is a valid absolute URI, "//" is not a valid relative one. The resulting exception: > [...] > Caused by: org.apache.http.ProtocolException: Invalid URI: http://www.google.com// > at org.apache.http.impl.client.DefaultRequestDirector.rewriteRequestURI(DefaultRequestDirector.java:339) > at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:434) > at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641) > ... 31 more > Caused by: java.net.URISyntaxException: Expected authority at index 2: // > at java.net.URI$Parser.fail(URI.java:2809) > at java.net.URI$Parser.failExpecting(URI.java:2815) > at java.net.URI$Parser.parseHierarchical(URI.java:3063) > at java.net.URI$Parser.parse(URI.java:3024) > at java.net.URI.(URI.java:578) > at org.apache.http.client.utils.URIUtils.createURI(URIUtils.java:106) > at org.apache.http.client.utils.URIUtils.rewriteURI(URIUtils.java:141) > at org.apache.http.client.utils.URIUtils.rewriteURI(URIUtils.java:159) > at org.apache.http.impl.client.DefaultRequestDirector.rewriteRequestURI(DefaultRequestDirector.java:333) > ... 33 more -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org