test: add LineReader edge cases relevant to HTTP parsing #35135

pull b-l-u-e wants to merge 1 commits into bitcoin:master from b-l-u-e:test/linereader-http-edge-cases changing 1 files +20 −0
  1. b-l-u-e commented at 9:18 PM on April 21, 2026: contributor

    This PR adds two small test cases to line_reader_test in src/test/util_string_tests.cpp to lock in util::LineReader behavior that upcoming HTTP request parsing will depend on.

    What the new cases check:

    • CRLF and trailing bare \r Consecutive CRLFs produce an empty line (this is how HTTP signals end of headers). A lone \r at the end of the buffer is not treated as a line terminator, so the rest can still be read with ReadLength().

    • State after a max_line_length exception After the exception, the iterator is reset and both Consumed() and Remaining() reflect that reset. This means callers can safely fall back to ReadLength() without losing position.

    LineReader was added in #34242 (commit 1911db8c) with the max_line_length + iterator-reset semantics exercised here. Consumed() was added later in #34905 (commit 81720992) so callers could observe position after an exception.

    These utilities are consumed by the in-progress libevent replacement (#32061). Adding these edge cases reduces risk and ambiguity

  2. test: add LineReader edge cases relevant to HTTP parsing
    Add two small test cases to line_reader_test that lock in
    current behavior LineReader-based HTTP parsing will depend on:
    
    - Consecutive CRLFs produce an empty line and a trailing bare \r
      is not treated as a line terminator.
    - Consumed()/Remaining() stay consistent with the reset iterator
      after a max_line_length exception, so ReadLength() can be used
      to recover.
    
    Signed-off-by: b-l-u-e <8102260+blue@users.noreply.github.com>
    72a8cfc31e
  3. DrahtBot added the label Tests on Apr 21, 2026
  4. DrahtBot commented at 9:18 PM on April 21, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me