The colon that became a value
A header parser includes the separator in values only when the optional space is absent.
What’s going wrong
A client accepts Header: value but reads Header:value as a different value. Stdin is zero or more ASCII header lines, terminated by LF or CRLF; the final LF is optional. Empty lines are ignored. Each nonempty line has a nonempty alphanumeric/hyphen name and a colon. Values contain printable ASCII and optional tabs, with no CR/LF inside. Total input is at most 8192 bytes.
Split on the first colon, discard that colon and all immediately following SP or TAB bytes, and preserve every later byte, including trailing spaces and additional colons. Preserve the name spelling. Print one JSON array of strings name|value in input order. The pipe in the output is just a separator after the name.
Repair the cursor calculation without requiring optional whitespace or deleting meaningful value bytes.
Expected behavior
Consume required separators independently of optional whitespace while preserving all meaningful value bytes.
Reproduction
Mode:fast
["Mode|fast"]
Mode: fast
["Mode|fast"]
X:
["X|"]
Before you begin
- Rust strings, slices and loops
- Read a failing example and compare exact output
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.