Skip to content

Commit

Permalink
Rename sendall to write to match interface on Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jul 12, 2016
1 parent f1b0923 commit a0b1d01
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions cherrypy/wsgiserver/wsgiserver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def read_request_headers(self):
msg = self.server.protocol.encode('ascii')
msg += b" 100 Continue\r\n\r\n"
try:
self.conn.wfile.sendall(msg)
self.conn.wfile.write(msg)
except socket.error:
x = sys.exc_info()[1]
if x.args[0] not in socket_errors_to_ignore:
Expand Down Expand Up @@ -874,7 +874,7 @@ def respond(self):
self.sent_headers = True
self.send_headers()
if self.chunked_write:
self.conn.wfile.sendall(b"0\r\n\r\n")
self.conn.wfile.write(b"0\r\n\r\n")

def simple_response(self, status, msg=""):
"""Write a simple response back to the client."""
Expand Down Expand Up @@ -908,7 +908,7 @@ def simple_response(self, status, msg=""):
buf.append(msg)

try:
self.conn.wfile.sendall(EMPTY.join(buf))
self.conn.wfile.write(EMPTY.join(buf))
except socket.error:
x = sys.exc_info()[1]
if x.args[0] not in socket_errors_to_ignore:
Expand All @@ -919,9 +919,9 @@ def write(self, chunk):
if self.chunked_write and chunk:
chunk_size_hex = hex(len(chunk))[2:].encode('ascii')
buf = [chunk_size_hex, CRLF, chunk, CRLF]
self.conn.wfile.sendall(EMPTY.join(buf))
self.conn.wfile.write(EMPTY.join(buf))
else:
self.conn.wfile.sendall(chunk)
self.conn.wfile.write(chunk)

def send_headers(self):
"""Assert, process, and send the HTTP response message-headers.
Expand Down Expand Up @@ -994,7 +994,7 @@ def send_headers(self):
for k, v in self.outheaders:
buf.append(k + COLON + SPACE + v + CRLF)
buf.append(CRLF)
self.conn.wfile.sendall(EMPTY.join(buf))
self.conn.wfile.write(EMPTY.join(buf))


class NoSSLError(Exception):
Expand All @@ -1018,7 +1018,7 @@ def __init__(self, *args, **kwargs):
self.bytes_written = 0
socket._fileobject.__init__(self, *args, **kwargs)

def sendall(self, data):
def write(self, data):
"""Sendall for non-blocking sockets."""
while data:
try:
Expand All @@ -1037,7 +1037,7 @@ def flush(self):
if self._wbuf:
buffer = "".join(self._wbuf)
self._wbuf = []
self.sendall(buffer)
self.write(buffer)

def recv(self, size):
while True:
Expand Down Expand Up @@ -2035,7 +2035,7 @@ def tick(self):

wfile = makefile(s._sock, "wb", DEFAULT_BUFFER_SIZE)
try:
wfile.sendall("".join(buf))
wfile.write("".join(buf))
except socket.error:
x = sys.exc_info()[1]
if x.args[0] not in socket_errors_to_ignore:
Expand Down

0 comments on commit a0b1d01

Please sign in to comment.