@@ -115,6 +115,8 @@ def parse(
115115
116116 The request method, path, and headers are expected to contain only ASCII
117117 characters. The request path isn't URL-decoded or validated in any way.
118+ Non-ASCII header values are decoded as ISO-8859-1, which has been
119+ historically allowed, but is now deprecated.
118120
119121 :meth:`parse` doesn't read the request body because WebSocket handshake
120122 requests don't have one. If the request contains a body, it may be read
@@ -127,6 +129,7 @@ def parse(
127129 Raises:
128130 EOFError: If the connection is closed without a full HTTP request.
129131 SecurityError: If the request exceeds a security limit.
132+ UnicodeDecodeError: If the request method or path isn't ASCII.
130133 ValueError: If the request isn't well formatted.
131134
132135 """
@@ -224,8 +227,9 @@ def parse(
224227
225228 This is a generator-based coroutine.
226229
227- The reason phrase and headers are expected to contain only ASCII
228- characters. Other characters are represented with surrogate escapes.
230+ The reason phrase and header values are expected to contain only ASCII
231+ characters. Non-ASCII values are decoded as ISO-8859-1, which has been
232+ historically allowed, but is now deprecated.
229233
230234 Args:
231235 read_line: Generator-based coroutine that reads a LF-terminated
@@ -339,7 +343,9 @@ def parse_headers(
339343 """
340344 Parse HTTP headers.
341345
342- Non-ASCII characters are represented with surrogate escapes.
346+ Header values are expected to contain only ASCII characters. Non-ASCII
347+ values are decoded as ISO-8859-1, which has been historically allowed,
348+ but is now deprecated.
343349
344350 Args:
345351 read_line: Generator-based coroutine that reads a LF-terminated line
0 commit comments