Recent

Author Topic: Trunk FPC: fphttpclient and proxies  (Read 2565 times)

Renat.Su

  • Full Member
  • ***
  • Posts: 159
    • Renat.Su
Trunk FPC: fphttpclient and proxies
« on: December 17, 2018, 05:18:08 pm »
I was told here that the proxy for the fphttpclient in the trunk version is implemented.
But when I looked at the source code in trunk lazarus (FPC 3.2.0), found at the top of the same comment:
Code: Pascal  [Select]
  1. { ---------------------------------------------------------------------
  2.   Todo:
  3.   * Proxy support ?
  4.   ---------------------------------------------------------------------}
Is there or is there no proxy support?.. Or it is there with some nuances?

Thaddy

  • Hero Member
  • *****
  • Posts: 9624
Re: Trunk FPC: fphttpclient and proxies
« Reply #1 on: December 17, 2018, 08:55:48 pm »
seems a bug in the comment
I am more like donkey than shrek

Renat.Su

  • Full Member
  • ***
  • Posts: 159
    • Renat.Su
Re: Trunk FPC: fphttpclient and proxies
« Reply #2 on: December 17, 2018, 09:17:43 pm »
seems a bug in the comment
Thank You!

GetMem

  • Hero Member
  • *****
  • Posts: 3561
Re: Trunk FPC: fphttpclient and proxies
« Reply #3 on: December 18, 2018, 06:21:00 am »
@Renat.Su
Please note that only http proxy is implemented. Do not try anything else, for example socks protocol will not work(SOCKS4, SOCKS4a, SOCKS5).

Thaddy

  • Hero Member
  • *****
  • Posts: 9624
Re: Trunk FPC: fphttpclient and proxies
« Reply #4 on: December 18, 2018, 08:42:37 am »
@Renat.Su
Please note that only http proxy is implemented. Do not try anything else, for example socks protocol will not work(SOCKS4, SOCKS4a, SOCKS5).
Correct, but these would be implemented elsewhere in the code base, probably fpsockets or in a separate unit.
I am more like donkey than shrek

Renat.Su

  • Full Member
  • ***
  • Posts: 159
    • Renat.Su
Re: Trunk FPC: fphttpclient and proxies
« Reply #5 on: December 18, 2018, 09:01:25 am »
@Renat.Su
Please note that only http proxy is implemented. Do not try anything else, for example socks protocol will not work(SOCKS4, SOCKS4a, SOCKS5).
Yes, I understand. To begin with http proxy would be nice

Renat.Su

  • Full Member
  • ***
  • Posts: 159
    • Renat.Su
Re: Trunk FPC: fphttpclient and proxies
« Reply #6 on: December 18, 2018, 09:58:38 pm »
Hm... Tested:
TFPHTTPClient:
HTTP -  worked
HTTPS - worked
HTTP with proxy - worked
HTTPS with proxy - not worked
That's sad. Unsecured sites at HTTP not so many, so it left turns proxies almost useless. Or I do not know some nuance?
P.S. Tested with various web sites and HTTP proxies
« Last Edit: December 18, 2018, 10:01:00 pm by Renat.Su »

Renat.Su

  • Full Member
  • ***
  • Posts: 159
    • Renat.Su
Re: Trunk FPC: fphttpclient and proxies
« Reply #7 on: January 03, 2019, 04:44:12 pm »
So, post the result of my research at the moment  %)
 
TFPHTTPClient
HTTP -  worked
HTTPS - worked
HTTP with proxy - worked (only trunk FPC)
HTTPS with proxy - not worked

Synapse HTTPClient THTTPSend class
HTTP -  worked
HTTPS - worked
HTTP with proxy - worked
HTTPS with proxy - worked (Windows)
HTTPS with proxy - not worked (Linux: Debian x86_84) or works with the hack (see post below)

Indy 10 HTTPClient TIdHTTP
HTTP -  worked
HTTPS - worked
HTTP with proxy - worked
HTTPS with proxy - worked   %)

Further

I wrote a basic client class emulating properties and functions (so far the ones I need) and separated the HTTP client from implementation. Accordingly, it will be possible to connect the required HTTP client by registering its implementation class. If anyone is interested - an example here
where
basehttpclient.pas - base abstract http client class
fphttpclientbroker.pas -native TFPHTTPClient implementation
synapsehttpclientbroker.pas - Synapse THTTPSend implementation
indyhttpclientbroker.pas - Indy TIdHTTP implementation
« Last Edit: February 12, 2020, 03:21:02 pm by Renat.Su »

Renat.Su

  • Full Member
  • ***
  • Posts: 159
    • Renat.Su
Re: Trunk FPC: fphttpclient and proxies
« Reply #8 on: February 12, 2020, 03:19:49 pm »
I found (thanks @ashumkin) the feature that I want to share with others if they encounter it
Synapse can works with proxy+HTTPS in Linux if change the code in the synapse library...
You must to comment or delete the line Port:= IntToStr(ResolvePort(Port)); in blcksock.pas
Code: Pascal  [Select]
  1. procedure TTCPBlockSocket.HTTPTunnelDoConnect(IP, Port: string);
  2. //bugfixed by Mike Green (mgreen@emixode.com)
  3. var
  4.   s: string;
  5. begin
  6.   //Port := IntToStr(ResolvePort(Port));
  7.   inherited Connect(FHTTPTunnelIP, FHTTPTunnelPort);
  8.   if FLastError <> 0 then
  9.     Exit;
  10.   FHTTPTunnel := False;