]> granicus.if.org Git - python/commitdiff
Issue #25738: Merge HTTP server from 3.5
authorMartin Panter <vadmium+py@gmail.com>
Wed, 8 Jun 2016 09:45:58 +0000 (09:45 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Wed, 8 Jun 2016 09:45:58 +0000 (09:45 +0000)
1  2 
Doc/library/http.server.rst
Lib/http/server.py
Lib/test/test_httpservers.py
Misc/ACKS
Misc/NEWS

Simple merge
index bd94eaa01b7814f9cc25267b0f64501a70be6890,00620d1f853fafa764631f22d000a59b3eb06ba7..e12e45bfc3809577ec861d04e870c38cad320972
@@@ -446,23 -450,30 +446,30 @@@ class BaseHTTPRequestHandler(socketserv
          if explain is None:
              explain = longmsg
          self.log_error("code %d, message %s", code, message)
-         # HTML encode to prevent Cross Site Scripting attacks (see bug #1100201)
-         content = (self.error_message_format % {
-             'code': code,
-             'message': html.escape(message, quote=False),
-             'explain': html.escape(explain, quote=False)
-         })
-         body = content.encode('UTF-8', 'replace')
          self.send_response(code, message)
-         self.send_header("Content-Type", self.error_content_type)
          self.send_header('Connection', 'close')
-         self.send_header('Content-Length', int(len(body)))
+         # Message body is omitted for cases described in:
+         #  - RFC7230: 3.3. 1xx, 204(No Content), 304(Not Modified)
+         #  - RFC7231: 6.3.6. 205(Reset Content)
+         body = None
+         if (code >= 200 and
+             code not in (HTTPStatus.NO_CONTENT,
+                          HTTPStatus.RESET_CONTENT,
+                          HTTPStatus.NOT_MODIFIED)):
+             # HTML encode to prevent Cross Site Scripting attacks
+             # (see bug #1100201)
+             content = (self.error_message_format % {
+                 'code': code,
 -                'message': _quote_html(message),
 -                'explain': _quote_html(explain)
++                'message': html.escape(message, quote=False),
++                'explain': html.escape(explain, quote=False)
+             })
+             body = content.encode('UTF-8', 'replace')
+             self.send_header("Content-Type", self.error_content_type)
+             self.send_header('Content-Length', int(len(body)))
          self.end_headers()
  
-         if (self.command != 'HEAD' and
-                 code >= 200 and
-                 code not in (
-                     HTTPStatus.NO_CONTENT, HTTPStatus.NOT_MODIFIED)):
+         if self.command != 'HEAD' and body:
              self.wfile.write(body)
  
      def send_response(self, code, message=None):
Simple merge
diff --cc Misc/ACKS
Simple merge
diff --cc Misc/NEWS
index 93bad2aa632bf0aebe053b671bdf6a678f20ae3f,47633743bdc453dd72eaf736ba879c04f508228e..b31120734f9bfdcf574853a9a1836617046c72c1
+++ b/Misc/NEWS
  Python News
  +++++++++++
  
 -What's New in Python 3.5.2 release candidate 1?
 -===============================================
 +What's New in Python 3.6.0 alpha 2
 +==================================
  
 -Release date: tba
 +*Release date: XXXX-XX-XX*
 +
 +Core and Builtins
 +-----------------
 +
 +- Issue #26983: float() now always return an instance of exact float.
 +  The deprecation warning is emitted if __float__ returns an instance of
 +  a strict subclass of float.  In a future versions of Python this can
 +  be an error.
 +
 +- Issue #27097: Python interpreter is now about 7% faster due to optimized
 +  instruction decoding.  Based on patch by Demur Rumed.
 +
 +- Issue #26647: Python interpreter now uses 16-bit wordcode instead of bytecode.
 +  Patch by Demur Rumed.
 +
 +- Issue #23275: Allow assigning to an empty target list in round brackets:
 +  () = iterable.
 +
 +Library
 +-------
 +
++- Issue #25738: Stop http.server.BaseHTTPRequestHandler.send_error() from
++  sending a message body for 205 Reset Content.  Also, don't send Content
++  header fields in responses that don't have a body.  Patch by Susumu
++  Koshiba.
++
 +- Issue #21313: Fix the "platform" module to tolerate when sys.version
 +  contains truncated build information.
 +
 +- Issue #26839: On Linux, :func:`os.urandom` now calls ``getrandom()`` with
 +  ``GRND_NONBLOCK`` to fall back on reading ``/dev/urandom`` if the urandom
 +  entropy pool is not initialized yet. Patch written by Colm Buckley.
 +
 +- Issue #23883: Added missing APIs to __all__ to match the documented APIs
 +  for the following modules: cgi, mailbox, mimetypes, plistlib and smtpd.
 +  Patches by Jacek Kołodziej.
 +
 +- Issue #27164: In the zlib module, allow decompressing raw Deflate streams
 +  with a predefined zdict.  Based on patch by Xiang Zhang.
 +
 +- Issue #24291: Fix wsgiref.simple_server.WSGIRequestHandler to completely
 +  write data to the client.  Previously it could do partial writes and
 +  truncate data.  Also, wsgiref.handler.ServerHandler can now handle stdout
 +  doing partial writes, but this is deprecated.
 +
 +- Issue #21272: Use _sysconfigdata.py to initialize distutils.sysconfig.
 +
 +- Issue #19611: :mod:`inspect` now reports the implicit ``.0`` parameters
 +  generated by the compiler for comprehension and generator expression scopes
 +  as if they were positional-only parameters called ``implicit0``.
 +  Patch by Jelle Zijlstra.
 +
 +- Issue #26809: Add ``__all__`` to :mod:`string`.  Patch by Emanuel Barry.
 +
 +- Issue #26373: subprocess.Popen.communicate now correctly ignores
 +  BrokenPipeError when the child process dies before .communicate()
 +  is called in more/all circumstances.
 +
 +- signal, socket, and ssl module IntEnum constant name lookups now return a
 +  consistent name for values having multiple names.  Ex: signal.Signals(6)
 +  now refers to itself as signal.SIGALRM rather than flipping between that
 +  and signal.SIGIOT based on the interpreter's hash randomization seed.
 +
 +- Issue #27167: Clarify the subprocess.CalledProcessError error message text
 +  when the child process died due to a signal.
 +
 +- Issue #25931: Don't define socketserver.Forking* names on platforms such
 +  as Windows that do not support os.fork().
 +
 +- Issue #21776: distutils.upload now correctly handles HTTPError.
 +  Initial patch by Claudiu Popa.
 +
 +- Issue #26526: Replace custom parse tree validation in the parser
 +  module with a simple DFA validator.
 +
 +- Issue #27114: Fix SSLContext._load_windows_store_certs fails with
 +  PermissionError
 +
 +- Issue #18383: Avoid creating duplicate filters when using filterwarnings
 +  and simplefilter.  Based on patch by Alex Shkop.
 +
 +- Issue #23026: winreg.QueryValueEx() now return an integer for REG_QWORD type.
 +
 +- Issue #26741: subprocess.Popen destructor now emits a ResourceWarning warning
 +  if the child process is still running.
 +
 +- Issue #27056: Optimize pickle.load() and pickle.loads(), up to 10% faster
 +  to deserialize a lot of small objects.
 +
 +- Issue #21271: New keyword only parameters in reset_mock call.
 +
 +- Issue #25548: Showing memory address of class objects in repl.
 +
 +IDLE
 +----
 +
 +- Issue #24759: Make clear in idlelib.idle_test.__init__ that the directory
 +  is a private implementation of test.test_idle and tool for maintainers.
 +
 +- Issue #27196: Stop 'ThemeChanged' warnings when running IDLE tests.
 +  These persisted after other warnings were suppressed in #20567.
 +  Apply Serhiy Storchaka's update_idletasks solution to four test files.
 +  Record this additional advice in idle_test/README.txt
 +
 +- Issue #20567: Revise idle_test/README.txt with advice about avoiding
 +  tk warning messages from tests.  Apply advice to several IDLE tests.
 +
 +- Issue # 24225: Update idlelib/README.txt with new file names
 +  and event handlers.
 +
 +- Issue #27156: Remove obsolete code not used by IDLE.  Replacements:
 +  1. help.txt, replaced by help.html, is out-of-date and should not be used.
 +  Its dedicated viewer has be replaced by the html viewer in help.py.
 +  2. 'import idlever; I = idlever.IDLE_VERSION' is the same as
 +  'import sys; I = version[:version.index(' ')]'
 +  3. After 'ob = stackviewer.VariablesTreeItem(*args)',
 +  'ob.keys()' == 'list(ob.object.keys).
 +  4. In macosc, runningAsOSXAPP == isAquaTk; idCarbonAquaTk == isCarbonTk
 +
 +- Issue #27117: Make colorizer htest and turtledemo work with dark themes.
 +  Move code for configuring text widget colors to a new function.
 +
 +- Issue #24225: Rename many idlelib/*.py and idle_test/test_*.py files.
 +  Edit files to replace old names with new names when the old name
 +  referred to the module rather than the class it contained.
 +  See the issue and IDLE section in What's New in 3.6 for more.
 +
 +- Issue #26673: When tk reports font size as 0, change to size 10.
 +  Such fonts on Linux prevented the configuration dialog from opening.
 +
 +- Issue #21939: Add test for IDLE's percolator.
 +  Original patch by Saimadhav Heblikar.
 +
 +- Issue #21676: Add test for IDLE's replace dialog.
 +  Original patch by Saimadhav Heblikar.
 +
 +- Issue #18410: Add test for IDLE's search dialog.
 +  Original patch by Westley Martínez.
 +
 +- Issue #21703: Add test for undo delegator.  Patch mostly by
 +  Saimadhav Heblikar .
 +
 +- Issue #27044: Add ConfigDialog.remove_var_callbacks to stop memory leaks.
 +
 +- Issue #23977: Add more asserts to test_delegator.
 +
 +Tests
 +-----
 +
 +- Issue #25285: regrtest now uses subprocesses when the -j1 command line option
 +  is used: each test file runs in a fresh child process. Before, the -j1 option
 +  was ignored.
 +
 +- Issue #25285: Tools/buildbot/test.bat script now uses -j1 by default to run
 +  each test file in fresh child process.
 +
 +Windows
 +-------
 +
 +- Issue #27064: The py.exe launcher now defaults to Python 3.
 +  The Windows launcher ``py.exe`` no longer prefers an installed
 +  Python 2 version over Python 3 by default when used interactively.
 +
 +Build
 +-----
 +
 +- Issue #27229: Fix the cross-compiling pgen rule for in-tree builds.  Patch
 +  by Xavier de Gaye.
 +
 +- Issue #26930: Update OS X 10.5+ 32-bit-only installer to build
 +  and link with OpenSSL 1.0.2h.
 +
 +
 +What's New in Python 3.6.0 alpha 1?
 +===================================
 +
 +Release date: 2016-05-16
  
  Core and Builtins
  -----------------