Commit c7253e7
Fix whitespace-only header line silently truncating headers (fix #222)
`ParserConfig::allow_space_before_first_header_name(true)` + a line
consisting only of whitespace right after the request/status-line
silently dropped the entire header block: the parser returned
Ok(Status::Complete) with headers == [], leaving every real header
unconsumed in the buffer for the caller to misinterpret as body/
next-request bytes.
After stripping the leading whitespace run, peek at the next byte
before continuing: whitespace-only (next byte is CR/LF) now rejects
with the same Error::HeaderName the non-leniency path already uses;
no more buffered data returns Status::Partial (preserves streaming
correctness). The documented, tested, non-degenerate case (space then
a real header) is unaffected.
Adds two regression tests (whitespace-only rejection on both request
and response sides; the Partial streaming case).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent a0fa552 commit c7253e7
1 file changed
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1102 | 1102 | | |
1103 | 1103 | | |
1104 | 1104 | | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1105 | 1115 | | |
1106 | 1116 | | |
1107 | 1117 | | |
| |||
2719 | 2729 | | |
2720 | 2730 | | |
2721 | 2731 | | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
| 2757 | + | |
| 2758 | + | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
| 2769 | + | |
| 2770 | + | |
| 2771 | + | |
| 2772 | + | |
| 2773 | + | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
2722 | 2778 | | |
2723 | 2779 | | |
2724 | 2780 | | |
| |||
0 commit comments