70 Commits
Author SHA1 Message Date
Brad Arant d7057ebb00 Fix JFile to normalize whitespace when loading JSON from disk
JString::operator=(ZString) already stripped whitespace between JSON
structural tokens before parsing, but JFile constructed via MFile file-
loading bypassed that path entirely, so any pretty-printed/hand-edited
JSON file silently failed every locate()/exists()/get*() call. Widen
removeWhitespace() to protected and call it from JFile constructor.
2026-08-25 19:14:14 -07:00
Brad ArantandClaude Sonnet 5 6b188fbee5 Restore execute bit on testing/compile (lost via UNC-path edit)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-25 10:42:48 -07:00
Brad ArantandClaude Sonnet 5 cb845efe69 Add HTTPRequest/HTTPResponse: real HTTP parsing on the Parser/StreamReader stack
Stage 2 of the APIServer plan. This codebase has only ever sat behind a
CGI gateway - IMFRequest/IMFResponse/IMFMessage predate the
StreamReader/Parser rebuild and are stubs (IMFResponse's header-emission
calls addHeader()/output(), neither of which exist on the class;
IMFRequest is a fragile non-resumable 3-token line split). Nothing in
this repo has ever actually parsed a raw HTTP request off a socket.

HTTPRequest : public Parser fills that gap the same way every other
Parser here is built: REQUEST_LINE -> HEADERS -> BODY -> DONE, chaining
LineParser (request line) and IMFHeader (headers, reused as-is - HTTP
header syntax is IMF-derived, nothing email-specific in IMFHeader
itself) via checkParse() over one shared StreamReader, exactly the
pattern CGIFormData already established for chaining IMFHeader/
IMFBoundary. The BODY state dispatches on Content-Type as CGIFormData
itself does for CGI bodies - application/x-www-form-urlencoded and
multipart/form-data delegate directly to CGIFormData (reused, not
reimplemented), anything else is captured as a raw body (e.g. JSON).
Query string is split off the path before anything else sees it.
getHeader() does a case-insensitive lookup (HTTP header names are
case-insensitive per RFC 7230, unlike IMFHeader's own std::map, which
compares byte-for-byte) since a route handler constantly needs this and
getting it wrong would be a silent framing bug, not a cosmetic one.

The boundary-extraction code mirrors __jet.cpp's own fix exactly (same
cursor-mutation trap: ZString::find() leaves the searched string's
cursor at the match, and CGIFormData's constructor copy-constructs its
own contentType member from whatever's passed in, inheriting that same
moved cursor unless reset() first - would otherwise silently miss its
own startsWith() dispatch checks).

HTTPResponse is a small, new, output-only builder (status line + a real
headers container + body, Content-Length auto-computed unless set
explicitly) - deliberately not patched from IMFResponse, which has
nothing safe to extend.

v1 limitations, flagged not fixed (matching the standard already set by
other Parser subclasses here for known-but-out-of-scope gaps): chunked
Transfer-Encoding isn't supported, and repeated header names last-wins
(inherited from IMFHeader's own std::map).

Verified live via testing/http_test.cpp (34 assertions, new - now wired
into testing/compile): byte-at-a-time GET with a query string and
case-insensitive header lookup; a GET with no query string; a POST with
an urlencoded body deliberately split mid-body (not just mid-header)
across two feed() calls, confirming the CGIFormData delegation resumes
correctly; a raw JSON POST body; testing/http_request.data (a real
fixture, previously unused - normalized from its stored LF line endings
to real CRLF, since HTTP requires CRLF and IMFHeader enforces that
strictly) fed byte-at-a-time; and HTTPResponse::serialize() both with an
auto-computed and an explicitly-set Content-Length (no duplicate
header). Also reran the full existing testing/compile suite
(zstring/mstring/jstring/mfile/jfile) against the rebuilt libCoreUtils.a
to confirm no regression from the two new files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-25 10:42:34 -07:00
Brad ArantandClaude Sonnet 5 a033cc6718 Add StreamReader and rebuild Parser/LineParser/IMFHeader/IMFBoundary on it
Introduces StreamReader to accumulate socket data delivered in arbitrary
chunks into one buffer, so a Parser can build an object (a line, a header
block, a MIME boundary) that spans any number of packets without losing
its place. Parser is redesigned around this: no longer inherits MString
(was redundant with its own buffer member), takes a StreamReader&, and
drives a resumable COMPLETE/INCOMPLETE/DATA_AVAIL state-machine protocol
via doParse(). LineParser, IMFHeader, and IMFBoundary are rewritten as
real, working resumable parsers against the shared buffer instead of the
previous non-compiling stubs (mismatched constructors/return types, a
syntax error, checkParse() never implemented).

IMFFormData is left as the stub it already was, just restored to
compiling against the new IMFHeader signature - fully wiring it up needs
IMFMultipart/IMFText migrated to StreamReader too, out of scope here.

Verified with real runtime tests (not just compilation) covering data
split mid-line, mid-CRLF, mid-header-fold, and mid-boundary-marker across
separate feed() calls, plus StreamReader::compact(). Along the way fixed
a header-value bug (space after ':' wasn't skipped) and a double
cursor-offset subtraction bug in two places caused by forgetting that
ZString::getLength() is already cursor-relative, not the raw buffer size.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-23 14:25:58 -07:00
Brad Arant ba85c5f2e5 Still parsing work. 2026-01-05 16:49:41 -08:00
Brad Arant 1542fbe218 Still working out cgi variable stuff. 2025-12-10 16:47:53 -08:00
Brad Arant ab748802ee JFile seems to work well now. 2025-12-09 08:46:33 -08:00
Brad Arant 4988f98223 Started work on JFile. 2025-12-04 17:04:55 -08:00
Brad Arant 829dc1a3c7 Fixed MString and MFile. 2025-12-04 16:40:11 -08:00
Brad Arant 5e6d162a05 added b64 encode/decode to MString. 2025-02-06 14:34:11 -08:00
Brad Arant c40e288a67 added trim operand function. 2025-01-16 13:38:35 -08:00
barant f8557aa5f5 migrating conversion modifiers from JetCore::Global to MString. 2024-12-19 10:32:23 -08:00
barant 10df4a6a99 added changed event handler. 2024-12-18 11:26:58 -08:00
barant 7eb2417456 added a pretty output to JString. 2024-12-18 09:49:34 -08:00
barant d74fa9689d added a pretty output to JString. Initial. 2024-12-17 16:56:05 -08:00
barant d1e5e41ab2 JString fix to compress initial assignment JSON. 2024-12-17 09:58:56 -08:00
barant 95254310f0 JString fix to compress initial assignment JSON. 2024-12-17 09:56:55 -08:00
barant 83e9b8ca99 bug fixes on mstring and jstring. 2024-12-12 15:47:09 -08:00
barant 0d60cce8dc more serious work on JString. 2024-12-12 12:22:46 -08:00
barant c6e0486c14 Serious work on JString and some minor MString ajustments. 2024-12-11 16:58:34 -08:00
barant 7531c885a7 JString now streams properly. 2024-12-11 09:55:40 -08:00
barant 0baa44d076 messing around with jstring. 2024-12-10 17:10:49 -08:00
brad Arant 6cd2fd6cc1 updated zstring_test to accomodate asInteger. 2024-11-27 15:18:32 -08:00
Brad Arant 8f5dd52c6a changed getTokenExclude method to allow escaped characters. 2024-11-14 09:44:12 -08:00
Brad Arant bf4ff3fdac Created destructive removeTrailingZeros() method on ZString. 2024-11-04 16:26:40 -08:00
Brad Arant d0239074a4 Fixed erroneous operator== on ZString. 2024-10-16 11:37:18 -07:00
Brad Arant 34e2ca0566 Fixed NULL assignment to ZString. 2024-10-16 11:15:54 -07:00
Brad Arant 8648ab3152 Added operator= integer operator. 2024-10-14 10:09:14 -07:00
Brad Arant e2d20a0c2d Changed startsWithDouble to startsWithNumber. 2024-09-26 12:32:04 -07:00
Brad Arant 974a509767 Fixed bug in asDouble but changed its operation. Decimal only. 2024-09-26 12:19:34 -07:00
Brad Arant 75df8d0282 Made find() return -1 if not found. 2024-09-24 14:19:25 -07:00
Brad Arant d7ef47cd49 Add trim to ZString. 2024-09-24 11:14:58 -07:00
Brad Arant a1cc142a59 Completed cosing of substring. 2024-08-08 11:42:09 -07:00
Brad Arant 39fd88cad9 Added startsWithDouble() method on ZString. 2024-08-01 15:03:28 -07:00
Brad Arant 0db4be8a99 Fixed operator< on ZString. 2024-07-31 13:03:45 -07:00
Brad Arant ad74a9de85 Completed ZString::compare method. 2024-07-24 17:01:25 +00:00
Brad Arant 6409bd2444 ignore string_tests. 2024-07-23 14:30:42 +00:00
Brad Arant 2adb523306 testing update. 2024-07-23 14:28:00 +00:00
Brad Arant d5bdfe8ca3 Added lineIsWhitespace function. 2024-07-11 13:53:53 -07:00
Brad Arant 81829f15f5 Added a zstring test. 2024-07-11 10:45:20 -07:00
Brad Arant cca957b948 Removed stringstream from assignment from double. 2024-07-09 08:29:43 -07:00
Brad Arant bfe5283492 Change c++17 to c++20. Fixed formatting on assignment from double. 2024-07-09 08:21:11 -07:00
brad Arant 363a6aa496 Fixed assignment of double to MString. 2024-07-08 18:27:05 -07:00
Brad Arant 1cfdc23a57 Added asDouble method to ZString. 2024-06-15 10:43:41 -07:00
Brad Arant beb3673241 Fixed == operator for empty string comparison. 2024-06-14 10:21:28 -07:00
Brad Arant f6e5e60e5b MString streaming work. 2024-03-26 11:09:07 -07:00
Brad Arant 77d5ea61dd Merge branch 'master' into develop 2024-03-20 11:03:44 -07:00
Brad Arant 37b9a5e316 Added ZString constructor for assignment on definition. 2024-02-16 14:38:04 -08:00
Brad Arant 2ad0d9a30c JString work. 2024-02-16 11:24:42 -08:00
Brad Arant d020363bc9 Trying to fix MString assignments. 2023-10-10 15:49:46 -07:00