Hello,
I'm having some difficulty making a GET request using fphttpclient with MacOS 10.15.7 Catalina. I've just upgraded to Lazarus 2.0.12 / fpc 3.2.0.
The code, which is intended to query the public api of an energy supplier, is pretty uncontroversial - and actually works fine on Linux Fedora 28.
function ToctopusForm.queryApi(api: string): string;
Var S : string;
HTTP : TFPHttpClient;
begin
result:='';
HTTP := TFPHttpClient.Create(nil);
HTTP.AllowRedirect:=True;
HTTP.AddHeader('User-Agent', 'Mozilla/5.0 (compatible; fpweb)');
HTTP.AddHeader('Content-Type', 'application/json');
try
S := HTTP.Get(api);
writeln(s);
result:=s;
finally
http.free;
end;
end;
openssl is installed via homebrew and openssl version -a returns:
OpenSSL 1.1.1h 22 Sep 2020
built on: Sat Oct 10 03:46:20 2020 UTC
platform: darwin64-x86_64-cc
options: bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: clang -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -D_REENTRANT -DNDEBUG
OPENSSLDIR: "/usr/local/etc/openssl@1.1"
ENGINESDIR: "/usr/local/Cellar/openssl@1.1/1.1.1h/lib/engines-1.1"
Seeding source: os-specific
I've also done
echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
as advised by homebrew and various blogs
I'm testing with
https://jsonplaceholder.typicode.com/todos/1 both this and the actual api I want to use work fine on Linux Fedora 28
The error is thrown in procedure TInetSocket.Connect and is ESocketError.
I'm pretty sure the issue is down to something in the openssl installation but I've tried everything I can think of.