You are not logged in.
I am using thttprequest from mormot2 inside a service to get response from an external API and I am using Tcurlhttp to do the connection (plus the USELIBCURL directive in the project's optionst)
The same code is compiled with delphi (windows) and FPC(Linux Ubuntu).
In windows it works OK with libcurl.dll v8.1.2.0 but in ubuntu linux (v7.81.0) I am getting the following error:
libcurl error 56 (Failure when receiving data from the peer)
I do not believe it is the difference between the curl version, because running the request from command line in linux, it works and it does not provide any error
The problem has probably to do with the input headers I add, as removing a header gives responce back.
I am adding the following way the headers:
headers:='Authorization: Basic '+BinToBase64(uname+':'+passw)+#10+'api-key: '+applkey+#10;
for n:=0 to high(headername) do
headers:=headers+headername[n]+': '+headervalue[n]+#10;
I noticed that leaving Authorization only, or api-key only, I get no curl error, but the usual response page from the rest server requesting both. The rest server I am contacting is not mormot.
it seems not be an FPC problem, compiled in windows 64bit with FPC it works OK.
Does anyone can imagine a reason for this behavior of curl in linux when used through mormot?
@ab is mormot2 using its own code-library for curl, and not ubuntu's curl?
Thank you in advance
Offline
Does anyone can imagine a reason for this behavior of curl in linux when used through mormot?
Have you tried making the request pure with curl in mORMot? I have posted examples for different scenarios in this thread and some others.
With best regards
Thomas
Offline
No and thats a good idea. I will test it. Thank you
Offline
For adding headers you can find an example here. Unfortunately, I have not created a list where I have written everywhere something on the topics. Must always search myself.
With best regards
Thomas
Offline
Thank you very much for your answers
The following code works OK in Ubuntu when running from an interface in mormot:
https://gist.github.com/dkounal/b8ab592 … 7536a31623
I tried the +#13+#10, error still exists.
Do you recommend something else?
I will try now the THttpClientSocket. Or should I use the TSimpleHttpClient?
Is it possible to use compression with THttpClientSocket?
Last edited by dcoun (2023-07-11 11:56:05)
Offline
To finish with this thread,
using thttprequest and curl does not works from linux compiled with FPC returning error 56.
Same code compiled with FPC for win64 works OK in windows.
Using the above gist code from inside mormot works ok for linux with linux
Headers were tested for both #13#10 and #10
I will try to check it again in the weekend.
Thank you all for the help. At least with curl it works now.
Last edited by dcoun (2023-07-14 09:43:32)
Offline
Try to remove last #13#10 in headers variable.
Offline
Try to remove last #13#10 in headers variable.
I returned back my code to check and I found that now it is not needed even that.
The same code from repository that did not work yesterday morning, it works today for linux.
The only change, is that I upgraded last night fpcupdeluxe and I did also an update to the same fixes version of FPC+Lazarus.
To be honest I am a bit afraid to use fpc....
PS I always do clean, delete and compile. Debugger does not work without that.
Thank you all again
Last edited by dcoun (2023-07-14 14:17:30)
Offline