Commit 368bf85
webserver: decompose post_iterator under the CCN 10 bar (21 -> 7)
webserver_impl::post_iterator is the MHD post-iterator trampoline:
called repeatedly per request as MHD feeds form fields and file
chunks. The original 82-line body wove together the non-file form-arg
path and the file-upload path (including memory and/or disk targets,
random vs sanitized filename, stream open/close on key/filename
transitions, write + size update). CCN 21.
Decomposed into per-responsibility helpers on detail::webserver_impl:
handle_post_form_arg static; form-arg path (set vs grow on off).
setup_new_upload_file_info per-instance; first-chunk filename choice
+ content_type/transfer_encoding seed.
Returns false if sanitize_upload_filename
fails so the caller maps it to MHD_NO.
manage_upload_stream static; close-on-transition, open-if-needed.
process_file_upload per-instance orchestrator for the disk
branch. Returns MHD_YES / MHD_NO.
post_iterator is now: dispatch (no filename -> handle_post_form_arg);
try-block with memory-target arg-flat update; disk-target dispatch to
process_file_upload; catch generateFilenameException -> MHD_NO. CCN 7.
Every new helper sits at CCN <= 8.
Static helpers are static because they don't read parent state
(handle_post_form_arg, manage_upload_stream); the disk-orchestrator
and setup_new_upload_file_info are instance methods because they
read parent->{file_upload_target, generate_random_filename_on_upload,
file_upload_dir}.
Behaviour preserved verbatim: the four-way OR that detects (filename,
key) transitions; the per-chunk grow vs replace based on @p off; the
unlink before opening to avoid appending to a leftover file; the
short-circuit returns of MHD_NO on sanitize failure and write failure.
Verified locally: full `make check`.
scripts/check-complexity.sh CCN_MAX ratcheted 22 -> 19 (the new worst
offenders are ip_representation::operator< and populate_all_cert_fields,
both CCN 18).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 5b86daf commit 368bf85
3 files changed
Lines changed: 110 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
516 | 542 | | |
517 | 543 | | |
518 | 544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1521 | 1521 | | |
1522 | 1522 | | |
1523 | 1523 | | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
1524 | 1600 | | |
1525 | 1601 | | |
1526 | 1602 | | |
1527 | 1603 | | |
1528 | 1604 | | |
1529 | | - | |
1530 | 1605 | | |
1531 | 1606 | | |
1532 | 1607 | | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
| 1608 | + | |
1541 | 1609 | | |
1542 | 1610 | | |
1543 | 1611 | | |
1544 | 1612 | | |
1545 | | - | |
| 1613 | + | |
| 1614 | + | |
1546 | 1615 | | |
1547 | | - | |
1548 | 1616 | | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
1600 | 1620 | | |
1601 | 1621 | | |
1602 | | - | |
| 1622 | + | |
1603 | 1623 | | |
1604 | 1624 | | |
1605 | 1625 | | |
| |||
0 commit comments