Skip to content

Commit 5034413

Browse files
committed
Move default_content_type to SimpleHTTPRequestHandler
1 parent aaafba8 commit 5034413

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

Doc/library/http.server.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,6 @@ instantiation, of which this module provides three different variants:
207207
header (using :meth:`send_header`) in all of its responses to clients.
208208
For backwards compatibility, the setting defaults to ``'HTTP/1.0'``.
209209

210-
.. attribute:: default_content_type
211-
212-
Specifies the Content-Type header value sent when the MIME type
213-
cannot be guessed from the file extension of the requested URL.
214-
By default, it is set to ``'application/octet-stream'``.
215-
216-
.. versionadded:: next
217-
218210
.. attribute:: MessageClass
219211

220212
Specifies an :class:`email.message.Message`\ -like class to parse HTTP
@@ -398,6 +390,14 @@ instantiation, of which this module provides three different variants:
398390
This will be ``"SimpleHTTP/" + __version__``, where ``__version__`` is
399391
defined at the module level.
400392

393+
.. attribute:: default_content_type
394+
395+
Specifies the Content-Type header value sent when the MIME type
396+
cannot be guessed from the file extension of the requested URL.
397+
By default, it is set to ``'application/octet-stream'``.
398+
399+
.. versionadded:: next
400+
401401
.. attribute:: extensions_map
402402

403403
A dictionary mapping suffixes into MIME types, contains custom overrides

Lib/http/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
290290
# the client gets back when sending a malformed request line.
291291
# Most web servers default to HTTP 0.9, i.e. don't send a status line.
292292
default_request_version = "HTTP/0.9"
293-
default_content_type = "application/octet-stream"
294293

295294
def parse_request(self):
296295
"""Parse a request (internal).
@@ -728,6 +727,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
728727
"""
729728

730729
server_version = "SimpleHTTP"
730+
default_content_type = "application/octet-stream"
731731
index_pages = ("index.html", "index.htm")
732732
extensions_map = _encodings_map_default = {
733733
'.gz': 'application/gzip',
@@ -1011,10 +1011,10 @@ def _get_best_family(*address):
10111011
return family, sockaddr
10121012

10131013

1014-
def test(HandlerClass=BaseHTTPRequestHandler,
1014+
def test(HandlerClass=SimpleHTTPRequestHandler,
10151015
ServerClass=ThreadingHTTPServer,
10161016
protocol="HTTP/1.0", port=8000, bind=None,
1017-
content_type=BaseHTTPRequestHandler.default_content_type,
1017+
content_type=SimpleHTTPRequestHandler.default_content_type,
10181018
tls_cert=None, tls_key=None, tls_password=None):
10191019
"""Test the HTTP request handler class.
10201020
@@ -1064,7 +1064,7 @@ def _main(args=None):
10641064
help='conform to this HTTP version '
10651065
'(default: %(default)s)')
10661066
parser.add_argument('--content-type',
1067-
default=BaseHTTPRequestHandler.default_content_type,
1067+
default=SimpleHTTPRequestHandler.default_content_type,
10681068
help='default content type for unknown extensions '
10691069
'(default: %(default)s)')
10701070
parser.add_argument('--tls-cert', metavar='PATH',

0 commit comments

Comments
 (0)