Hi Oleg, Thanks for your answer. I did the reading on java.net.URI and RFC 2396. In java.net.URI, the URI normalization is mentioned as "Normalization is the process of removing unnecessary "." and ".." segments from the path component of a hierarchical URI." In RFC 2396, the normalization is mentioned in the section regarding the case insensitivity of the host name. I see no reference in normalizing "/" character.
Given the fact that 1. All the browsers (IE, Chrome, Firefox) are able to submit the URIs without normalizing the leading "/" character. 2. From the App's perspective, http://<hostname>:<port>/xyz and http://<hostname>:<port>///xyz are different resources. Here is the reason behind multiple leading "/" in the App's URL, "The slashes in the App's URL are a way to reference a file system instead of a network resource. The web server has an inherent current directory -- the first two // means a URL redirect, and the next the leading / means a local file reference." I am questioning if the leading slash characters need to be normalized at all in httpclient library. I identified the class, org.apache.http.client.utils.URIUtils.URIBuilder, where it performs the "/" normalization. The method is normalizePath(). I am tempted to modify the piece of code to see if apache client library (v4.2.3) can be tailored to work for my project. Kind Regards, Nick On Tue, Jul 8, 2014 at 12:37 PM, Oleg Kalnichevski <[email protected]> wrote: > On Mon, 2014-07-07 at 17:46 -0400, Nick Chang wrote: >> Hello, >> >> Here is a simple code sniplet to reproduce the issue. >> >> public static void main(String[] args) throws Exception { >> DefaultHttpClient httpclient = new DefaultHttpClient(); >> HttpGet httpGet = new HttpGet("http://www.google.com///imghp"); >> >> HttpResponse response1 = httpclient.execute(httpGet); >> >> try { >> System.out.println(response1.getStatusLine()); >> HttpEntity entity1 = response1.getEntity(); >> // do something useful with the response body >> // and ensure it is fully consumed >> EntityUtils.consume(entity1); >> } finally { >> httpGet.releaseConnection(); >> } >> >> } >> >> The httpclient library will only send out '/imghp' in the HTTP Request. The >> additional leading slash characters are omitted. Anyway to configure >> DefaultHttpClient to preserve the additional leading slash characters? >> > > This is called URI normalization and has nothing to do with HttpClient. > See java.net.URI and RFC 2396. > > One cannot make HttpClient 4.2 send requests with a non-normalized URI. > You'll need to upgrade to version 4.3 and use BasicHttpRequest instead > of HttpGet. > > Oleg > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
