Commit graph

128 commits

Author SHA1 Message Date
Yorhel
0cd947c545 FastCGI: Ignore HTTP_CONTENT_(TYPE|LENGTH)
The non-HTTP_ versions of these are authoritative, Also fixes a memory
leak when both the HTTP_ and non-HTTP_ versions are included.
2025-04-25 09:34:22 +02:00
Yorhel
e88ad65232 Version 0.5 2025-04-24 14:16:17 +02:00
Yorhel
4833456898 FU: Accept charset argument in JSON request content-type header 2025-04-24 10:50:50 +02:00
Yorhel
ab168bd952 Pg: Don't return self on / cache() or text_*() methods
This is much too easy of a footgun:

  $db->cache->q(...);

Enabled cache on the $db object, not just for the given query.
2025-04-24 07:23:03 +02:00
Yorhel
13271fa413 Minor changes & fixes 2025-04-23 16:12:39 +02:00
Yorhel
8096de7497 MultipartFormData: Fix ->save() on zero-length values 2025-04-22 18:54:04 +02:00
Yorhel
91b2421a84 FU: Add -procname import option and setting $0 to something useful 2025-04-22 09:32:56 +02:00
Yorhel
ea8ad9e483 FU: Throw and handle FU::Validate errors directly
Instead of wrapping them in a FU::err that isn't easily inspected.
2025-04-20 18:37:59 +02:00
Yorhel
1594006739 FU: Improve merging of "Vary" response headers + debug header listing 2025-04-20 11:40:27 +02:00
Yorhel
f2294a709a FU: Fix warning when calling fu->set_header() with undef value 2025-04-20 11:31:15 +02:00
Yorhel
8b807e6dcf Validate: Add empty() and coerce() methods
Implementing the undocumented coerce_for_json() method from TUWF and
elm_empty() from VNDB.
2025-04-19 12:36:28 +02:00
Yorhel
efa63ca96a Pg: Discard temporary hash keys earlier in $st->kv? methods
Saves some memory for large query results, didn't notice much of a
performance difference.
2025-04-07 16:52:47 +02:00
Yorhel
196b1cc3ce FU: Use CLOCK_MONOTONIC for timing 2025-04-07 16:41:29 +02:00
Yorhel
e7a9f165de Fix use of SvPVXtrue() where SvTRUEx() was intended 2025-04-07 14:29:21 +02:00
Yorhel
b3281924d1 Pg: Add escape_literal() and escape_identifier()
Didn't expect I'd ever need these, but they're useful for generating SQL
scripts.
2025-04-07 13:45:33 +02:00
Yorhel
3bf98e4d8f FU: Fix fu->reset also resetting cookies 2025-04-03 15:58:38 +02:00
Yorhel
13661b46f9 Validate: Normalize num/int/uint to Perl numeric types + add 64bit limit to int/uint
Normalization may be undone by later validations, but this should work
in most cases.
2025-03-30 13:55:23 +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
0925ae79a1 XS: Ensure created Perl strings are nul-terminated
Most of these are binary strings and shouldn't be interpreted as C
strings in the first place, but better be safe in case they are, anyway.
The lack of nul-termination of FU::Pg `$hex` strings was more likely to
be problematic.
2025-03-19 17:34:42 +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
a7bfe146b1 Validate: Fix referencing & merging already compiled schemas 2025-03-17 12:50:24 +01:00
Yorhel
65cf842500 FU: Some fixes and consistency in fu->json and fu->formdata 2025-03-16 18:26:57 +01:00
Yorhel
3382deba9a Validate: Rename "scalar" to "accept_scalar" and add "accept_array" 2025-03-16 15:39:10 +01:00
Yorhel
f8fe53cba9 json_format: Add html_safe option 2025-03-16 15:03:32 +01:00
Yorhel
3fad7feec3 Validate: Rename "values"->"elems", repurpose "values" to validate hash values
I'm breaking stuff left and right while I still can.

Idea: "key_names" validation?

Idea: "tuple" validation that works like "keys" but for arrays.
  (i.e. { tuple => { $index => $schema } }, could make "missing" and
  "unknown" work for arrays, too)
2025-03-14 16:52:33 +01:00
Yorhel
fa24ca53e3 Validate: improved arrayref-schema semantics
This allows all built-in options to be duplicated inside a single
schema, the semantics of which are the same as the kind of merging
done as part of inheriting options from custom validations.

This also causes all 'keys' and 'values' validation schemas to be
merged, which changes error messages a bit but is great for
introspection. Probably slightly improves performance as well.
2025-03-14 14:28:28 +01:00
Yorhel
cea691dd55 Validate: drop creation of default values for built-ins
To better support merging multiple validations, which'll come next.
Probably.
2025-03-14 10:52:12 +01:00
Yorhel
f248a33c1c Validate: Allow multiple func validations in arrayref schema 2025-03-14 09:25:56 +01:00
Yorhel
1363e11269 Validate: allow array schemas + defer known_keys hash creation
Doesn't allow multiple 'func' options yet, needs work.
2025-03-14 07:28:11 +01:00
Yorhel
64a105e013 Validate: remove a level of indirection 2025-03-14 07:27:59 +01:00
Yorhel
9685287523 Version 0.3 2025-03-10 12:43:02 +01:00
Yorhel
d9d2ad0434 Pg: Add COPY support 2025-03-10 12:32:14 +01:00
Yorhel
dc752e2a23 Pg: Support dynamic-oid types + vndbtag/vndbid 2025-03-09 10:23:48 +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
e4b6b77e1b Validate: rename rmwhitespace to trim and use builtin::trim() 2025-03-05 15:39:49 +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
f09a103c53 Some test portability fixes again + minor changes 2025-03-02 10:10:35 +01:00
Yorhel
3fd424c6e3 Compat fixes + 0.2 release 2025-02-28 14:05:48 +01:00
Yorhel
15954f4ad5 Pg: Add "$hex" pseudo-type 2025-02-28 13:49:07 +01:00
Yorhel
baf0f90bd5 Pg: Add "time" type, change default format of "date" type but support "$date_str"
Using a consistent numeric interpretation for timestamps, dates and
times simplifies a bunch of operations. It certainly simplifies
conversion between the Postgres formats.
2025-02-28 13:03:16 +01:00