Skip to content

Commit

Permalink
Fix some misplaced parenthesis and spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-otto committed Mar 21, 2020
1 parent 7375c2c commit 0b130d2
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions cheroot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"""

from __future__ import absolute_import, division, print_function

__metaclass__ = type

import os
Expand Down Expand Up @@ -91,19 +92,16 @@
from .workers import threadpool
from .makefile import MakeFile, StreamWriter


__all__ = (
'HTTPRequest', 'HTTPConnection', 'HTTPServer',
'HeaderReader', 'DropUnderscoreHeaderReader',
'SizeCheckWrapper', 'KnownLengthRFile', 'ChunkedRFile',
'Gateway', 'get_ssl_adapter_class',
)


IS_WINDOWS = platform.system() == 'Windows'
"""Flag indicating whether the app is running under Windows."""


IS_GAE = os.getenv('SERVER_SOFTWARE', '').startswith('Google App Engine/')
"""Flag indicating whether the app is running in GAE env.
Expand All @@ -112,11 +110,9 @@
/using-local-server#detecting_application_runtime_environment
"""


IS_UID_GID_RESOLVABLE = not IS_WINDOWS and not IS_GAE
"""Indicates whether UID/GID resolution's available under current platform."""


if IS_UID_GID_RESOLVABLE:
try:
import grp
Expand All @@ -131,14 +127,12 @@
grp, pwd = None, None
import struct


if IS_WINDOWS and hasattr(socket, 'AF_INET6'):
if not hasattr(socket, 'IPPROTO_IPV6'):
socket.IPPROTO_IPV6 = 41
if not hasattr(socket, 'IPV6_V6ONLY'):
socket.IPV6_V6ONLY = 27


if not hasattr(socket, 'SO_PEERCRED'):
"""
NOTE: the value for SO_PEERCRED can be architecture specific, in
Expand All @@ -147,7 +141,6 @@
"""
socket.SO_PEERCRED = 21 if IS_PPC else 17


LF = b'\n'
CRLF = b'\r\n'
TAB = b'\t'
Expand All @@ -160,7 +153,6 @@
QUOTED_SLASH = b'%2F'
QUOTED_SLASH_REGEX = re.compile(b''.join((b'(?i)', QUOTED_SLASH)))


comma_separated_headers = [
b'Accept', b'Accept-Charset', b'Accept-Encoding',
b'Accept-Language', b'Accept-Ranges', b'Allow', b'Cache-Control',
Expand All @@ -170,7 +162,6 @@
b'WWW-Authenticate',
]


if not hasattr(logging, 'statistics'):
logging.statistics = {}

Expand Down Expand Up @@ -533,7 +524,7 @@ def _fetch(self):
raise ValueError(
'Bad chunked transfer size: {chunk_size!r}'.
format(chunk_size=chunk_size),
)
)

if chunk_size <= 0:
self._read_trailers()
Expand All @@ -555,7 +546,7 @@ def _fetch(self):
raise ValueError(
"Bad chunked transfer coding (expected '\\r\\n', "
'got ' + repr(crlf) + ')',
)
)

def read(self, size=None):
"""Read a chunk from ``rfile`` buffer and return it.
Expand Down Expand Up @@ -793,7 +784,7 @@ def parse_request(self):
self.inheaders[header[0]] = header[1]

if (b'transfer-encoding' in self.inheaders and
self.inheaders[b'transfer-encoding'].lower() == b"chunked"):
self.inheaders[b'transfer-encoding'].lower() == b"chunked"):
self.chunked_read = True

uri_is_absolute_form = scheme or authority
Expand Down Expand Up @@ -1020,7 +1011,6 @@ def send_headers(self):
self.conn.wfile.write(res_bytes)



class HTTPConnection:
"""An HTTP connection (active socket)."""

Expand Down Expand Up @@ -1101,7 +1091,7 @@ def communicate(self):
self.server.error_log(
'socket.error %s' % repr(errnum),
level=logging.WARNING, traceback=True,
)
)
self._conditional_error(req, '500 Internal Server Error')
except (KeyboardInterrupt, SystemExit):
raise
Expand Down

0 comments on commit 0b130d2

Please sign in to comment.