[Python-checkins] cpython: whatsnew: http.server send_error explain parameter.

r.david.murray python-checkins at python.org
Fri Jan 3 19:04:58 CET 2014


http://hg.python.org/cpython/rev/8ade807624a5
changeset: 88277:8ade807624a5
user: R David Murray <rdmurray at bitdance.com>
date: Fri Jan 03 13:03:00 2014 -0500
summary:
 whatsnew: http.server send_error explain parameter.
Also rewrote the send_error description for clarity and correct English.
files:
 Doc/library/http.server.rst | 15 +++++++++------
 Doc/whatsnew/3.4.rst | 12 ++++++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/Doc/library/http.server.rst b/Doc/library/http.server.rst
--- a/Doc/library/http.server.rst
+++ b/Doc/library/http.server.rst
@@ -116,7 +116,7 @@
 HTTP error code value. *message* should be a string containing a
 (detailed) error message of what occurred, and *explain* should be an
 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
 
@@ -173,11 +173,14 @@
 .. method:: send_error(code, message=None, explain=None)
 
 Sends and logs a complete error reply to the client. The numeric *code*
- specifies the HTTP error code, with *message* as optional, more specific
- text, usually referring to short message response. The *explain*
- argument can be used to send a detailed information about the error in
- response content body. A complete set of headers is sent, followed by
- text composed using the :attr:`error_message_format` class variable.
+ specifies the HTTP error code, with *message* as an optional, short, human
+ readable description of the error. The *explain* argument can be used to
+ provide more detailed information about the error; it will be formatted
+ using the :attr:`error_message_format` class variable and emitted, after
+ 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
 The error response includes a Content-Length header.
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -684,6 +684,18 @@
 (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
 ---------
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /