summaryrefslogtreecommitdiff
path: root/cherrypy/wsgiserver/wsgiserver2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cherrypy/wsgiserver/wsgiserver2.py')
-rw-r--r--cherrypy/wsgiserver/wsgiserver2.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/cherrypy/wsgiserver/wsgiserver2.py b/cherrypy/wsgiserver/wsgiserver2.py
index 7bcf216f..a386d73d 100644
--- a/cherrypy/wsgiserver/wsgiserver2.py
+++ b/cherrypy/wsgiserver/wsgiserver2.py
@@ -103,6 +103,10 @@ except ImportError:
# Python 2.6
import io
+try:
+ import pkg_resources
+except ImportError:
+ pass
if 'win' in sys.platform and hasattr(socket, "AF_INET6"):
if not hasattr(socket, 'IPPROTO_IPV6'):
@@ -114,6 +118,12 @@ if 'win' in sys.platform and hasattr(socket, "AF_INET6"):
DEFAULT_BUFFER_SIZE = io.DEFAULT_BUFFER_SIZE
+try:
+ cp_version = pkg_resources.require('cherrypy')[0].version
+except Exception:
+ cp_version = 'unknown'
+
+
class FauxSocket(object):
"""Faux socket with the minimal interface required by pypy"""
@@ -192,6 +202,8 @@ socket_errors_to_ignore = plat_specific_errors(
)
socket_errors_to_ignore.append("timed out")
socket_errors_to_ignore.append("The read operation timed out")
+if sys.platform == 'darwin':
+ socket_errors_to_ignore.append(plat_specific_errors("EPROTOTYPE"))
socket_errors_nonblocking = plat_specific_errors(
'EAGAIN', 'EWOULDBLOCK', 'WSAEWOULDBLOCK')
@@ -298,7 +310,7 @@ class SizeCheckWrapper(object):
self.bytes_read += len(data)
self._check_length()
res.append(data)
- # See https://bitbucket.org/cherrypy/cherrypy/issue/421
+ # See https://github.com/cherrypy/cherrypy/issues/421
if len(data) < 256 or data[-1:] == LF:
return EMPTY.join(res)
@@ -798,7 +810,7 @@ class HTTPRequest(object):
if self.inheaders.get("Expect", "") == "100-continue":
# Don't use simple_response here, because it emits headers
# we don't want. See
- # https://bitbucket.org/cherrypy/cherrypy/issue/951
+ # https://github.com/cherrypy/cherrypy/issues/951
msg = self.server.protocol + " 100 Continue\r\n\r\n"
try:
self.conn.wfile.sendall(msg)
@@ -1361,7 +1373,7 @@ class HTTPConnection(object):
# Don't error if we're between requests; only error
# if 1) no request has been started at all, or 2) we're
# in the middle of a request.
- # See https://bitbucket.org/cherrypy/cherrypy/issue/853
+ # See https://github.com/cherrypy/cherrypy/issues/853
if (not request_seen) or (req and req.started_request):
# Don't bother writing the 408 if the response
# has already started being written.
@@ -1654,7 +1666,7 @@ class ThreadPool(object):
except (AssertionError,
# Ignore repeated Ctrl-C.
# See
- # https://bitbucket.org/cherrypy/cherrypy/issue/691.
+ # https://github.com/cherrypy/cherrypy/issues/691.
KeyboardInterrupt):
pass
@@ -1754,7 +1766,7 @@ class HTTPServer(object):
timeout = 10
"""The timeout in seconds for accepted connections (default 10)."""
- version = "CherryPy/5.1.0"
+ version = "CherryPy/" + cp_version
"""A version string for the HTTPServer."""
software = None
@@ -1979,7 +1991,7 @@ class HTTPServer(object):
# If listening on the IPV6 any address ('::' = IN6ADDR_ANY),
# activate dual-stack. See
- # https://bitbucket.org/cherrypy/cherrypy/issue/871.
+ # https://github.com/cherrypy/cherrypy/issues/871.
if (hasattr(socket, 'AF_INET6') and family == socket.AF_INET6
and self.bind_addr[0] in ('::', '::0', '::0.0.0.0')):
try:
@@ -2073,15 +2085,15 @@ class HTTPServer(object):
# the call, and I *think* I'm reading it right that Python
# will then go ahead and poll for and handle the signal
# elsewhere. See
- # https://bitbucket.org/cherrypy/cherrypy/issue/707.
+ # https://github.com/cherrypy/cherrypy/issues/707.
return
if x.args[0] in socket_errors_nonblocking:
# Just try again. See
- # https://bitbucket.org/cherrypy/cherrypy/issue/479.
+ # https://github.com/cherrypy/cherrypy/issues/479.
return
if x.args[0] in socket_errors_to_ignore:
# Our socket was closed.
- # See https://bitbucket.org/cherrypy/cherrypy/issue/686.
+ # See https://github.com/cherrypy/cherrypy/issues/686.
return
raise
@@ -2114,7 +2126,7 @@ class HTTPServer(object):
if x.args[0] not in socket_errors_to_ignore:
# Changed to use error code and not message
# See
- # https://bitbucket.org/cherrypy/cherrypy/issue/860.
+ # https://github.com/cherrypy/cherrypy/issues/860.
raise
else:
# Note that we're explicitly NOT using AI_PASSIVE,