Commit daefe476 authored by R David Murray's avatar R David Murray

whatsnew: http.server send_error explain parameter.

Also rewrote the send_error description for clarity and correct English.
parent da7f697a
...@@ -116,7 +116,7 @@ of which this module provides three different variants: ...@@ -116,7 +116,7 @@ of which this module provides three different variants:
HTTP error code value. *message* should be a string containing a HTTP error code value. *message* should be a string containing a
(detailed) error message of what occurred, and *explain* should be an (detailed) error message of what occurred, and *explain* should be an
explanation of the error code number. Default *message* and *explain* explanation of the error code number. Default *message* and *explain*
values can found in the *responses* class variable. values can found in the :attr:`responses` class variable.
.. attribute:: error_content_type .. attribute:: error_content_type
...@@ -173,11 +173,14 @@ of which this module provides three different variants: ...@@ -173,11 +173,14 @@ of which this module provides three different variants:
.. method:: send_error(code, message=None, explain=None) .. method:: send_error(code, message=None, explain=None)
Sends and logs a complete error reply to the client. The numeric *code* Sends and logs a complete error reply to the client. The numeric *code*
specifies the HTTP error code, with *message* as optional, more specific specifies the HTTP error code, with *message* as an optional, short, human
text, usually referring to short message response. The *explain* readable description of the error. The *explain* argument can be used to
argument can be used to send a detailed information about the error in provide more detailed information about the error; it will be formatted
response content body. A complete set of headers is sent, followed by using the :attr:`error_message_format` class variable and emitted, after
text composed using the :attr:`error_message_format` class variable. a complete set of headers, as the response body. The :attr:`responses`
class variable holds the default values for *message* and *explain* that
will be used if no value is provided; for unknown codes the default value
for both is the string ``???``.
.. versionchanged:: 3.4 .. versionchanged:: 3.4
The error response includes a Content-Length header. The error response includes a Content-Length header.
......
...@@ -684,6 +684,18 @@ The *strict* argument of :class:`~html.parser.HTMLParser` is now deprecated. ...@@ -684,6 +684,18 @@ The *strict* argument of :class:`~html.parser.HTMLParser` is now deprecated.
(Contributed by Ezio Melotti in :issue:`15114`) (Contributed by Ezio Melotti in :issue:`15114`)
http
----
:meth:`~http.server.BaseHTTPRequestHandler.send_error` now accepts an
optional additional *exaplain* parameter which can be used to provide an
extended error description, overriding the hardcoded default if there is one.
This extended error description will be formatted using the
:attr:`~http.server.HTTP.error_message_format` attribute and sent as the body
of the error response. (Contributed by Karl Cow in :issue:`12921`.)
importlib importlib
--------- ---------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment