A THTTPClient issue with HTTP proxies, and a workaround

The development of the JSON RPC framework started on 10th Feb. I was inspired by the QP report that I've filed last year, and developed the JSON RPC framework, according to the JSON RPC 2.0 specification, with the exception that batch calls are currently not supported.

The framework can use either the Indy components, or the System.Net components. The framework is currently implemented over HTTP, though it can be easily separated such that it runs over TCP, UDP, WebSockets, instead of just HTTP only.

One of the quirks I've discovered with one of the components I've used, THTTPClient (from the System.Net.HttpClient unit) when developing the JSON RPC framework is the way it works with a HTTP proxy.

When you use THTTPClient on Windows with a HTTP proxy, and if the destination is "localhost", THTTPClient ignores the proxy totally. The workaround is to add a dot suffix to the destination, such that "localhost" becomes "localhost.". Then, THTTPClient will then send the request through the HTTP proxy.

Published Thu, 21 Feb 2019 @ 5:48 PM by chuacw
Related articles: , ,