You are not logged in.
Hello, I don’t understand how to make https requests via mORMot to get the source code of the page, can you please tell me an example of the code and which library to include?
Offline
uses
mormot.core.base,
mormot.core.data,
mormot.core.os,
mormot.net.client;
var
content: RawByteString;
begin
content := HttpGet('https://tile.openstreetmap.org/10/549/339.png');
if content <> '' then
FileFromString(content, ChangeFileExt(ExeVersion.ProgramFileName, '.png'));
With best regards
Thomas
Offline
Thanks a lot, but for example I need to use my own user agent and proxy ?
I figured it all out, but I didn’t understand one thing: does it automatically determine the type of proxy HTTP, SOCKS4, SOCKS5 ?
procedure TForm2.Button1Click(Sender: TObject);
var
H:TSimpleHttpClient;
begin
H:=TSimpleHttpClient.Create(False);
h.UserAgent:='.....................';
h.Proxy:=????;
h.Request('https://', 'GET');
Memo1.Lines.Add(h.Body);
h.Free;
end;
Last edited by Uefi (2024-06-26 22:20:56)
Offline
i add another question here.
This is very easy to use and seems to be very smooth!
Is there a possibility to use a socks5 proxy or is only a http proxy possible?
Offline
Sadly, only HTTP (or HTTPS) proxies are supported yet.
Hello, should you submit a proxy directly :
h.Proxy:='0.0.0.0:8080'; // ?
I would also put KeepAlive, Header, Data, DataMimeType into separate entries since this is more convenient than:
http.Request(URL, 'GET', '', '', '', 100);
And it would be:
http.KeepAlive:=100;
http.Header.Add('Content-Type: text/html; charset=utf-8'); // Better here TStringlist
http.Data:='';
http.DataMimeType:='application/json';
Please reconsider this as I have found that http requests in mORMot are fast, much faster than Synapse!
Last edited by Uefi (2024-06-27 16:43:02)
Offline
TSimpleHttpClient is very easy to use then other solutions, and it is 10x times faster than delphi TNetHTTPClient,
but it missing compressions, need to add RegisterCompress after fHttps := MainHttpClass.Create or fHttp := THttpClientSocket.Open.
another thing is, our mormot httpclient do NOT handle cookies set by server (response header Set-Cookie:), delphi TNetHTTPClient handle cookies automaticly, but it is too slow,
TWinHttp handle cookies , but it's buggy.
it will be nice if it has these features.
Last edited by keinn (2024-07-01 09:53:39)
Offline
Sadly, only HTTP (or HTTPS) proxies are supported yet.
go through many docs, it is not easy to use Proxies features with our mORMot.
programer these days use delphi /pascal , do not have much high quality components to use, it is sad.
mormot2 is definely top one framework in pascal/delphi field.
http/https/socks5 proxy is very usefull feature, we are so behind other languages.
python4delphi is away to make up for this regret.
as a framework , mORMot do everything from scratch, it is too much work.
maybe ,mORMot should just wrap up well-known, excellent, and widely accepted third-party components to catch up.
like curl wrap up, or some c++ interface wrap up,
like https://github.com/salvadordf/ocvWrapper46.git (wraps up openCV)
https://github.com/pyscripter/python4delphi.git (python)
https://github.com/salvadordf/WebView4Delphi.git (cef ,webview)
Offline
Hey @Ab
is it possible to use a socks5 proxy with libcurl?
I read that HttpGet does not use compression per default.
What would you advice to use performance wise for downloading text from a website programmatically?
I googled quite some time to find an example how to use libcurl with a proxy - do you have a quick sample for me?
thanks!
Offline