Recent

Author Topic: HttpClient using named pipe  (Read 1730 times)

Pascal

  • Hero Member
  • *****
  • Posts: 932
HttpClient using named pipe
« on: May 20, 2020, 10:13:37 pm »
Is there a way to use TFPHTTPClient (fphttpclient) with a named pipe?

I would like to build a docker client but don't want to build the whole http stuff, which is needed for the rest api, again.

The named pipe for docker is \\.\pipe\docker_engine.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Loesje

  • Full Member
  • ***
  • Posts: 168
    • Lazarus Support website
Re: HttpClient using named pipe
« Reply #1 on: May 25, 2020, 10:06:35 pm »
Ehm... are you sure that the docker-engine uses HTTP as the protocol when you connect to it using a pipe?

Woudn't that be strange? But then again, it could work...

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: HttpClient using named pipe
« Reply #2 on: May 26, 2020, 09:03:03 am »
Yes, i am sure! See Develop with Docker Engine API.
On Windows the named pipe is the default to communicate to the docker engine.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

Thaddy

  • Hero Member
  • *****
  • Posts: 14210
  • Probably until I exterminate Putin.
Re: HttpClient using named pipe
« Reply #3 on: May 26, 2020, 09:10:58 am »
Yes, i am sure! See Develop with Docker Engine API.
On Windows the named pipe is the default to communicate to the docker engine.
There is no reason that should not work, but plz use https, not http, and install proper certificates.
Specialize a type, not a var.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: HttpClient using named pipe
« Reply #4 on: May 26, 2020, 09:19:56 am »
I have not tested it, but you'll probably need to implement your own TSocketHandler class that can deal with named pipes. You can use that in the TFPHTTPClient either by overriding GetSocketHandler or by setting OnGetSocketHandler.

Please note that from what I've read the named pipe is only accessible if your application is running with elevated privileges, so if you want your application to run as a normal user you must use an ordinary network connection instead.

Pascal

  • Hero Member
  • *****
  • Posts: 932
Re: HttpClient using named pipe
« Reply #5 on: May 26, 2020, 03:45:53 pm »
I have not tested it, but you'll probably need to implement your own TSocketHandler class that can deal with named pipes. You can use that in the TFPHTTPClient either by overriding GetSocketHandler or by setting OnGetSocketHandler.

Thanks for the clues.

Please note that from what I've read the named pipe is only accessible if your application is running with elevated privileges, so if you want your application to run as a normal user you must use an ordinary network connection instead.

That's right. Unfortunately, as the docker daemon runs in an hyper-v vm, there is no way to connect to it via network. At least i do not know of one.
laz trunk x64 - fpc trunk i386 (cross x64) - Windows 10 Pro x64 (21H2)

 

TinyPortal © 2005-2018