You are not logged in.
Pages: 1
Hello!
Congratulation for this great project.
uos (United Openlib of Sound) use fpc TFPHTTPClient to do audio from web radios.
It works mostly great on Linux but some http.Http.Head() fail to connect (but using curl it is ok) and with Windows there are problems with
Could not initialize openssl library.
Also, there are problems with:
Http.AddHeader('Range', 'bytes=0-1023');
Http.Get(URL, ms);
The 'Range' is not done, all is downloading.
This is the unit that does the work for web-streams:
https://github.com/fredvs/uos/blob/main … thread.pas
Should it be possible to use mORMot to do this job and would it be complicated to "translate" the code to be compatible with mORMot?
Thanks.
Fre;D
Offline
You could indeed use mORMot 2 to have a HTTP client.
There are several classes... I would perhaps just use the THttpClientSocket class.
On Windows, it could use SChannel for HTTPS so no OpenSSL is needed.
Reconnections should be automatic, like redirection and such.
You even have a WGET-like feature if huge content is needed (maybe for podcasts, not web stream).
It can support proxy and ranges too.
But note that we have limited BSD testing yet - beside MacOS which is well tested.
Offline
OK, perfect.
Are there simple demos THttpClientSocket to do http.get and http.head?
For example in the uos project to access web stream, is it possible to use mormot even for console or MSEgui/fpGUI apps?
Offline
Hello.
OK, I think that the conversion done with my new friend AI Gork seems promising.
But the code fails at linking with this:
/usr/bin/ld: cannot find ../../static/x86_64-linux/sha512-x64sse4.o: No such file or directory
/usr/bin/ld: cannot find ../../static/x86_64-linux/crc32c64.o: No such file or directory
/usr/bin/ld: cannot find ../../static/x86_64-linux/libdeflatepas.a: No such file or directory
I did copy the files in /home/fred/swp_work/src/mormot2static/x86_64-linux and used the fpc parameter -Fl/home/fred/swp_work/src/mormot2static/x86_64-linux but still same error.
Sadly my friend AI Gork is tired, it cannot help me and I dont see what to do.
Last edited by fredvs (2025-04-11 23:08:07)
Offline
Ok,ok, ok,
>I did copy the files in /home/fred/swp_work/src/mormot2static/x86_64-linux and used the fpc parameter -Fl/home/fred/swp_work/src/mormot2static/x86_64-linux but still same error.
>Sadly my friend AI Gork is tired, it cannot help me and I dont see what to do.
Copying the files there: /home/fred/static did the job (a few strange but ok).
But it does not work so I have to jump into mormot and try to understand why it does not work yet.
Offline
Some news from the front.
I did try to access a web audio mp3 radio: http://icecast.radiofrance.fr/fip-midfi.mp3
Tested with curl and it access.
Here the mormot code used to try to access it:
uses
mormot.net.client,
mormot.core.base,
...
Writeln('Testing fallback stream: http://icecast.radiofrance.fr/fip-midfi.mp3'); // Debug
URL := 'http://icecast.radiofrance.fr/fip-midfi.mp3';
HttpHeaders := 'User-Agent: Mozilla/5.0';
try
Writeln('Sending fallback GET request to: ', URL); // Debug
Writeln('Headers sent: ', HttpHeaders); // Debug
Status := Http.Request(URL, 'GET', 0, HttpHeaders, '', HttpHeaders, False);
Writeln('Fallback GET Status: ', Status); // Debug
if Status = 200 then
begin
Response := Http.Content;
Writeln('Fallback Content length: ', Length(Response)); // Debug
end
else
Writeln('Fallback GET failed with status: ', Status); // Debug
except
on E: Exception do
begin
Writeln('Fallback GET Exception: ', E.Message); // Debug
end;
end;
--------------------
But I get this as debug:
Testing fallback stream: http://icecast.radiofrance.fr/fip-midfi.mp3
Sending fallback GET request to: http://icecast.radiofrance.fr/fip-midfi.mp3
Headers sent: User-Agent: Mozilla/5.0
Fallback GET Status: 666
Fallback GET failed with status: 666
----------------------
What did I wrong?
Offline
Please follow the forum rules and don't post code directly in the forum thread.
Ooops, I did not know this, but without code it is difficult to explain the problem.
Install mORMot as a Lazarus package, as documented.
I dont use Lazarus, sorry.
Last edited by fredvs (2025-04-11 23:36:17)
Offline
Yes, I am using FPC 3.2.2.
And you are confusing the URI and the resource name.
Hum, it is totally possible because I dont know what is URI (I know URL) and what is resource name.
And also, I confess it, the code was done by Gork AI.
Last edited by fredvs (2025-04-11 23:33:53)
Offline
Ok, a fast ask gives: The main difference is in what they do: URIs identify resources, while URLs locate them.
So, the code is for URI, and it use a URL, is it so (or reverse)?
Offline
After a looong white night, I am finally be able to connect the url (or uri) and get the header of the audio stream:
Http := THttpClientSocket.Create(5000);
if Pos('http://', URL) = 1 then
Delete(URL, 1, 7);
Host := Copy(URL, 1, Pos('/', URL) - 1);
Resource := Copy(URL, Pos('/', URL), MaxInt);
if Resource = '' then
Resource := '/';
Http.Open(Host, '80');
Http.Request(Resource, 'GET', 0, HttpHeaders, '', HeadersOut, True);
Response := Http.Content;
I will stop now and attack the GET of the audio stream via pipe later.
(I you have advice's, they are welcome).
Last edited by fredvs (2025-04-12 02:38:27)
Offline
You have TUri for parsing the URL/URI.
And THttpClientSocket.OpenUri() to avoid parsing.
Look at TNetworkProtocols.RunPeerCacheDirect
or THttpClientSocketWGet.WGet for usage of this method.
Offline
You have TUri for parsing the URL/URI.
And THttpClientSocket.OpenUri() to avoid parsing.Look at TNetworkProtocols.RunPeerCacheDirect
or THttpClientSocketWGet.WGet for usage of this method.
Many thanks, I will jump deeply into it.
Does it exist demos of this?
Offline
Pages: 1