Commit graph

41 commits

Author SHA1 Message Date
Yorhel
196b1cc3ce FU: Use CLOCK_MONOTONIC for timing 2025-04-07 16:41:29 +02:00
Yorhel
3bf98e4d8f FU: Fix fu->reset also resetting cookies 2025-04-03 15:58:38 +02:00
Yorhel
2f50736782 fdpass_recv: Set O_CLOEXEC on received fds
Turns out this is necessary even if the fd is going to be passed through
exec() soon, because the supervisor might receive multiple fds before
spawning another process, in which case all of them are going to be
passed to the new process instead of just one.
2025-03-24 11:07:39 +01:00
Yorhel
9e1be5bc71 FU: Log errors thrown from error handler 2025-03-22 15:10:59 +01:00
Yorhel
17584f2b8c FU: Fix DB reconnect + not setting debug_info() 2025-03-22 14:58:38 +01:00
Yorhel
90881924d4 Doc fixes 2025-03-21 11:31:20 +01:00
Yorhel
7c765f33bb Version 0.4 2025-03-19 10:54:23 +01:00
Yorhel
6159b33950 FU::Util: Add brotli_compress() and use it for FU output compression
Seems to compresses and perform better than libdeflate at level 6, so
certainly worth using.
2025-03-19 10:12:20 +01:00
Yorhel
bc33fe53f0 FU::Util: Add gzip_compress() wrapper for libdeflate/zlib-ng/zlib
And use it for automatic output compression in FU, as (potentially)
faster alternative to Compress::Raw::Zlib.

Was also planning to maybe add support for Zstd or Brotli, but given the
performance of libdeflate, I'm not sure that's really necessary. Brotli
does tend to do a better job at compressing HTML, though.
2025-03-18 16:59:43 +01:00
Yorhel
c2e0f158ac FU: Add fu->cookie() 2025-03-17 16:18:12 +01:00
Yorhel
d8ecc71abb FU: Add fu->set_cookie() (+ uri_unescape '+' fix) 2025-03-17 13:46:14 +01:00
Yorhel
65cf842500 FU: Some fixes and consistency in fu->json and fu->formdata 2025-03-16 18:26:57 +01:00
Yorhel
9685287523 Version 0.3 2025-03-10 12:43:02 +01:00
Yorhel
70c5199df4 FU: Add JSON reading & writing methods 2025-03-08 15:49:43 +01:00
Yorhel
17176738a0 FU: Support multipart file uploads + some doc fixes
API is not super convenient and implementation is lousy, but uploading
files is not a super common operation so that should be fine.

At least it supports large files with only a single in-memory copy.
2025-03-08 14:06:10 +01:00
Yorhel
e5755ddd80 Validate: Human-readable error messages 2025-03-06 10:16:14 +01:00
Yorhel
cbebc3a21e Validate: Rework API, ->validate() now throws error instead of result object
This is a slight simplification and removes the need to pass around
partially normalized data. I've never found a use for the unsafe_data()
method.
2025-03-05 15:35:23 +01:00
Yorhel
7839e7df78 FU: Fix typo in error handling 2025-03-02 21:09:59 +01:00
Yorhel
3fd424c6e3 Compat fixes + 0.2 release 2025-02-28 14:05:48 +01:00
Yorhel
3662931fc2 FU: Add "denied" and "notfound" convenience methods 2025-02-27 14:00:28 +01:00
Yorhel
b06cc24826 FU: Add super awesome and butt-ugly FU::debug_info web interface
This is so much more useful than embedding debugging info inside pages,
as I've been doing before.
2025-02-27 13:44:25 +01:00
Yorhel
8dca0a22a9 FU: Add randomized --max-reqs option 2025-02-26 11:31:15 +01:00
Yorhel
29dd09e809 FU: Drop Zstd support
Compress::Zstd decided to bundle libzstd instead of linking to the
system lib, and it predictably hasn't been updated in 6 years. I
consider that broken to the point of DO-NOT-USE.

Maybe I'll do a custom dlopen() wrapper for that later, but for now
let's just stick with gzip.
2025-02-26 08:59:36 +01:00
Yorhel
7b0ba45346 Docs, compatibility fixes again, 0.1 release 2025-02-25 17:02:33 +01:00
Yorhel
69262992ca FU::Validate: Add module + integrate with FU
Copied from TUWF::Validate with a few small changes. I have a few more
features planned, but let's see how this goes first.

It's been an incredibly useful module in the past, I'm not sure right
now if I had ideas for potential improvements at some point, will need
to check notes.
2025-02-25 14:31:38 +01:00
Yorhel
06e2f950fe Add fu->redirect, change $st->row behavior on 0 results, minor fixes
And with this, I have a working rewrite of the manned.org backend into
FU. \o/

The $st->row methods are very useful even for queries that may not
return anything, so their old behavior was unhelpful. Interestingly
enough, the error-on-multiple-rows did catch an actual bug in
Manned.org, so I'm keeping that behavior.
2025-02-24 15:55:27 +01:00
Yorhel
8595c4ba64 FU: HTTP date handling + fu->send_file 2025-02-24 11:12:01 +01:00
Yorhel
18e642290d Some fixes and framework docs 2025-02-23 14:05:43 +01:00
Yorhel
a5f9584b02 FU::Log: Add logger and basic integration with FU 2025-02-21 17:13:32 +01:00
Yorhel
145d086bea Add FU::SQL
Somewhat experimental, need to test this approach on a real site.
Looking pretty promising so far, though.
2025-02-20 15:45:55 +01:00
Yorhel
48d3fb86a5 FU: Revert integration with XMLWriter & import options; copyright stuff
Realized that, since html_() now returns a string, it's just as easy to
just pass that to fu->set_body(); no need for integration complexity.

Combined import options don't save much typing, not worth the overhead
either.
2025-02-20 08:46:03 +01:00
Yorhel
d0665ef7c2 FU: Output compression, XMLWriter integration, import options, some docs 2025-02-19 16:55:43 +01:00
Yorhel
67e6d99f01 Add query string encoding & decoding functions 2025-02-18 14:08:23 +01:00
Yorhel
90cfd66069 FU: Some FastCGI fixes; FU::Util: utf8_decode & URI escaping 2025-02-18 10:27:58 +01:00
Yorhel
d9fba4e8d8 FU: Add FastCGI support + bunch of fixes
I initially planned to only implement the bare minimum to support
FastCGI under nginx, but ended up implementing the full protocol
instead. This is more code than I had expected and the code is also less
trivial than I had hoped. Will need to do more testing, pretty sure
there's bugs left.

Also TODO: test under alternative process managers + document
FU_LISTEN_PROTO.

I've also removed the max_request_body setting, this is something that
really ought to be configured in the web server instead.
2025-02-17 15:15:38 +01:00
Yorhel
3e84a4f4d3 FU: Implement --monitor, add some docs; FU::Util: add fdpass functions 2025-02-15 15:09:56 +01:00
Yorhel
09fe50d2a2 FU: Add supervisor daemon thingy
A little tricky to get right, but it works pretty well.

TODO: Do something with --monitor.

I initially wanted to avoid the exec() and just let Perl continue
running the rest of the script after fork(), but that runs into the
problem that perl really doesn't like it when you fork() in BEGIN.
2025-02-14 14:39:44 +01:00
Yorhel
08410e56f5 FU: More frameworking stuff
It's actually somewhat usable already.

Except this a lot of code without documentation or tests...
2025-02-14 06:42:51 +01:00
Yorhel
b15c70d3c6 FU: Small start on the actual website framework
Not fully done with FU::Pg yet, but could use a change of pace.
2025-02-13 14:48:54 +01:00
Yorhel
abfbba3c10 Add some tests and move some docs 2025-02-01 07:00:09 +01:00
Yorhel
9c80f2465a Init 2025-01-26 15:32:47 +01:00