Skip to content

docs(ch21-01): clarify HTTP request-header end-of-headers signaling (#4574)#4786

Open
Dodothereal wants to merge 1 commit into
rust-lang:mainfrom
Dodothereal:fix/issue-4574-http-request-header-end
Open

docs(ch21-01): clarify HTTP request-header end-of-headers signaling (#4574)#4786
Dodothereal wants to merge 1 commit into
rust-lang:mainfrom
Dodothereal:fix/issue-4574-http-request-header-end

Conversation

@Dodothereal

Copy link
Copy Markdown

Closes #4574

Summary

Replace

The browser signals the end of an HTTP request by sending two newline
characters in a row, so to get one request from the stream, we take lines until
we get a line that is the empty string.

with

The browser signals the end of an HTTP request header by sending a
carriage return and newline character twice in a row, so to get the
headers of one request from the stream, we take lines until we get
a line that is the empty string.

\\r\\n\\r\\n marks the end of the request headers, not the end of the
entire request — the request body (if any) follows the blank line and
is not delimited by another blank line. The original wording overstates
what the snippet parses.

Also tighten "so to get one request from the stream" to "so to get the
headers of one request", since the snippet below only reads header
lines.

Test plan

  • mdbook build compiles the chapter cleanly.
  • dprint fmt reports no changes; the diff is whitespace-stable.

AI assistance

Drafted with assistance from Claude; reviewed line by line before
submission. rust-lang/book has no formal AI policy, so this
disclosure is offered as good practice.

…ust-lang#4574)

The original text reads:

    The browser signals the end of an HTTP request by sending two newline
    characters in a row, so to get one request from the stream, we take lines until
    we get a line that is the empty string.

That's not precise: \\r\\n\\r\\n marks the end of the request headers —
not the end of the entire request, which has a body that isn't delimited
by a blank line. Replace with the issue's suggested phrasing:

    The browser signals the end of an HTTP request header by sending a
    carriage return and newline character twice in a row, so to get the
    headers of one request from the stream, we take lines until we get
    a line that is the empty string.

Also tighten 'so to get one request ...' to 'so to get the headers of
one request ...' since the code below only consumes the header lines;
it does not handle the body.

Closes rust-lang#4574
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chapter 21 Building a Single-Threaded Web Server - incorrect http request definition

1 participant