Recent

Author Topic: Any really functional webserver suite for FPC ?  (Read 2502 times)

zim

  • New Member
  • *
  • Posts: 17
Any really functional webserver suite for FPC ?
« on: December 18, 2023, 09:34:40 am »
Is there any really functional suite for HTTP-HTTPS available for FPC under Linux ?
Spent a week trying to make it work - no progress at all.

Indy for Delphi + SSL patch for openssl 1.1/3.0 - works perfectly. But all attempts to make it work under FPC or Lazarus fail.
Either code from my Delphi package or OPM code - not work.
Everything stops on content encoding conversion, iconv conversion returns no bytes.

Same with Synapse. Any unicode symbols in reply are returning incorrectly.

Where's that old good Kylix code...

abouchez

  • Full Member
  • ***
  • Posts: 115
    • Synopse
Re: Any really functional webserver suite for FPC ?
« Reply #1 on: December 18, 2023, 10:25:35 am »
Of course, I would recommend our Open Source https://github.com/synopse/mORMot2
It is a full client/server suite, and support latest OpenSSL 3.x (no need to patch anything).
It was meant to write REST/JSON services, but you can use it to serve some HTTP/HTTPS content, even with a Mustache-based template system.

With amazing performance - top #12 framework in the TemchEmpower Benchmarks - it has been deeply optimized for Linux (e.g. it uses epoll for its asynchrnous HTTP/HTTPS server, and we even wrote our own multi-thread friendly heap manager for FPC x86_64 Linux).
https://blog.synopse.info/?post/2023/10/31/Pascal-in-the-race%3A-TFB-Challenge-Benchmarks

See https://github.com/synopse/mORMot2/tree/master/ex/mvc-blog
for a MVC blog.
See https://github.com/synopse/mORMot2/tree/master/ex/ThirdPartyDemos/tbo
for some demos - for Delphi, but you can read the text (German & English), look at the code and get your idea.

There are some other frameworks too of course, for FPC.
Don't use Indy, because it is not OpenSSL 3.x ready, and not very FPC friendly.
But you have also known alternatives, like fcl-web or Brooks.
« Last Edit: December 18, 2023, 10:27:24 am by abouchez »

dpremus

  • New Member
  • *
  • Posts: 32
Re: Any really functional webserver suite for FPC ?
« Reply #2 on: December 18, 2023, 09:38:49 pm »
I am using Horse

https://github.com/HashLoad/horse

It works with Lazarus & Delphi

zim

  • New Member
  • *
  • Posts: 17
Re: Any really functional webserver suite for FPC ?
« Reply #3 on: December 19, 2023, 11:30:31 am »
I finally had found the problem, better say several problems. First, fpjson unit is half-working, method TJsonObject.Find returns False even if element with the specified name is 100% available.
Next, Lazarus RC2 randomly does not recompile modified units, and no chance to make them compile but manually delete of units folder.
Lazarus itself hang or produces AV periodically

Still some strange problems with unicode - -Mdelphi make it compile (but with non-unicode strings), while -Mdelphiunicode returns strange errors cannot be explained.
Btw, I had commented some components used, as FPC produces internal error compiling them.

Thanks for the advice, will check links

PascalDragon

  • Hero Member
  • *****
  • Posts: 5585
  • Compiler Developer
Re: Any really functional webserver suite for FPC ?
« Reply #4 on: December 19, 2023, 10:11:24 pm »
First, fpjson unit is half-working, method TJsonObject.Find returns False even if element with the specified name is 100% available.

Please report a bug for this with a reproducible, small, self contained example that shows the issue.

Still some strange problems with unicode - -Mdelphi make it compile (but with non-unicode strings), while -Mdelphiunicode returns strange errors cannot be explained.

The DelphiUnicode only changes String = UnicodeString for the unit that it's compiled with. So especiallly precompiled units (like the RTL or the LCL) will not use UnicodeString for String. Essentially it is currently not recommended to use that mode. The next major release will provide a real Unicode RTL for selected targets (no, there is currently no timeframe for when it will be released). So best stay with the normal AnsiString and the UTF-8 encoding that Lazarus uses.

Btw, I had commented some components used, as FPC produces internal error compiling them.

Same as above: please provide small, self contained examples that show the issue.

If we don't know about something we can't fix it after all.

zeljko

  • Hero Member
  • *****
  • Posts: 1617
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Any really functional webserver suite for FPC ?
« Reply #5 on: June 12, 2024, 12:12:31 pm »
I am using Horse

https://github.com/HashLoad/horse

It works with Lazarus & Delphi

But horse ssl support needs indy as I can see.

egsuh

  • Hero Member
  • *****
  • Posts: 1395
Re: Any really functional webserver suite for FPC ?
« Reply #6 on: June 12, 2024, 02:23:05 pm »
Does mOrMot support FCGI?

Thaddy

  • Hero Member
  • *****
  • Posts: 15177
  • Censorship about opinions does not belong here.
Re: Any really functional webserver suite for FPC ?
« Reply #7 on: June 12, 2024, 02:26:46 pm »
Not very relevant since FCGI is stand-alone.
But yes, therefor the serverside mORMot supports it for that reason.
Most if not any server can support FCGI.
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

Warfley

  • Hero Member
  • *****
  • Posts: 1513
Re: Any really functional webserver suite for FPC ?
« Reply #8 on: June 12, 2024, 03:06:05 pm »
You should not expose your websever directly. Use a production webserver like nginx or apache as reverse proxy or as CGI application instead. The reason for this is simply that these projects are heavily tested, audited and used by millions of people, with very active development teams, such that security vulnerabilities will be found and patched quickly, and you can also be sure that it will provide for all the niche features and edgecases.

This is not just for pascal, but you'll see the same recommendation given for pretty much all other systems such as pythons flask framework. It's generally considered best practize.

This also means that you don't have to care about TLS and stuff like that within your application, as the webserver will take care of it

Thaddy

  • Hero Member
  • *****
  • Posts: 15177
  • Censorship about opinions does not belong here.
Re: Any really functional webserver suite for FPC ?
« Reply #9 on: June 12, 2024, 06:29:24 pm »
Well, that is somewhat correct, but in general a front-end (or multiple front-ends) hide a collection of web servers. The front-end server itself is usually static.
Of course the national anthem of the U.S.A. was written by Jimi Hendrix, didn't you know that?

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1351
    • Lebeau Software
Re: Any really functional webserver suite for FPC ?
« Reply #10 on: June 12, 2024, 10:17:40 pm »
Indy for Delphi + SSL patch for openssl 1.1/3.0 - works perfectly. But all attempts to make it work under FPC or Lazarus fail.
Either code from my Delphi package or OPM code - not work.
Everything stops on content encoding conversion, iconv conversion returns no bytes.

Can you elaborate?  Indy's use of iconv in FPC is experimental at best, not really tested, but this is the first time I'm hearing that it doesn't work.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018