Fiddler Ideas

The free web debugging proxy for any browser, system or platform.

HTTP error 400 when accessing domain without trailing slash from Java

I get HTTP error 400 every time I try to access url without the trailing slash from Java. This code works fine without proxy or when using other proxy software (I'm using Windows 10 and latest Java 8) so I suspect it's a Fiddler bug.

System
.setProperty("java.net.useSystemProxies", "true");
URL res = new URL("http://en.wikipedia.org");
HttpURLConnection request = (HttpURLConnection) res.openConnection();
request.connect();
request.getDoOutput();
System.out.println(request.getResponseCode());

  • Guest
  • Apr 4 2017
  • Under review
Bug
  • Attach files
  • Eric Lawrence commented
    4 Apr, 2017 04:15pm

    This is actually a bug in Java; it's not legal to request a URL without the trailing slash.

    Other proxies might add one, but Fiddler isn't doing so and it passes the request to the server without the slash. The server, knowing the request is illegal, complains back to the client application by returning a HTTP/400 error.

    If you have protocol violation reporting enabled, Fiddler shows you the following notice:

    [ProtocolViolation] Incorrectly formed Request-Line. abs_path was empty (e.g. missing /). RFC2616 Section 5.1.2