Proposal - TFPCustomHTTPClient support of HTTP over unix domain socket
Summary
Allow HTTP client the possibility to connect using unix domain socket, due to security concerns, http clients are not always expected to connect only using tcp based http servers.
Example
https://docs.podman.io/en/latest/_static/api.html
curl --unix-socket /run/podman/podman.sock http://d/v3.0.0/libpod/info
- Docker has it exposed too as a unix socket https://docs.docker.com/engine/api/v1.24/
What is the current bug behavior?
New feature, not bug
What is the behavior after applying this patch?
The users will be able to use it in a very simple way, just as expected HTTP client
Var
S : String;
begin
With TFPCustomHTTPClient.Create(nil) do
try
UnixSocketPath := '/tmp/podman.sock';
S := Get('http://d/v3.0.0/libpod/info');
Results.Append(S);
WriteLn(S);
finally
Free;
end;
end;
- The curl client has built-in support for it these days
- A well known JS http client library, axios, has
socketPath
init argument to support it - https://axios-http.com/docs/req_config - Unix sockets are very useful for these scenarios too, even Windows supports it from 2017 - https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows
See discussion - https://forum.lazarus.freepascal.org/index.php/topic,39141.0.html