title: HttpClient, How to send illegal characters in URI string
body: <p>I'd like to come up with some automated tests to validate my servers handling of invalid request URIs. For example, a tester was able to send this as his url using curl on windows:</p>
  
  <pre><code>http://127.0.0.1/C:\an\incorrect\path\file.txt
  </code></pre>
  
  <p>I have handling on the server to deal with that, but still want to add tests if possible. Tried to do it with HttpClient but HttpClient doesn't like the invalid characters ;)</p>
  
  <pre><code>// Run client
                  String Url = targetHost + filePath + fileName;
                  HttpClient httpclient = new DefaultHttpClient();
                  HttpPost httppost = new HttpPost(Url);
  
                  // run test
                  InputStreamEntity reqEntity = new InputStreamEntity(new FileInputStream(sourceDir.getAbsolutePath() + LusConstants.DIR_SEPERATOR + fileName),-1);
                  reqEntity.setContentType("binary/octet-stream");
                  reqEntity.setChunked(chunked);
                  httppost.setEntity(reqEntity);
                  httpclient.execute(httppost);
  </code></pre>
  
  <p>Exception from HttpClient:</p>
  
  <pre><code>aused by: java.net.URISyntaxException: Illegal character in path at index 39: http://127.0.0.1:8080//a/deeper/path/an\incorrect\path\file.txt
      at java.net.URI$Parser.fail(Unknown Source)
      at java.net.URI$Parser.checkChars(Unknown Source)
      at java.net.URI$Parser.parseHierarchical(Unknown Source)
      at java.net.URI$Parser.parse(Unknown Source)
      at java.net.URI.&lt;init&gt;(Unknown Source)
      ... 4 more
  </code></pre>
  
  <p>Any thoughts? </p>