mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use boud tests rather than equality tests
This commit is contained in:
parent
85d85a6d98
commit
9842272aac
@ -363,7 +363,7 @@ class HTTPConnection(HTTPRequest):
|
|||||||
end = buf.tell()
|
end = buf.tell()
|
||||||
buf.seek(pos)
|
buf.seek(pos)
|
||||||
limit = end - pos
|
limit = end - pos
|
||||||
if limit == 0:
|
if limit <= 0:
|
||||||
return True
|
return True
|
||||||
if self.use_sendfile and not isinstance(buf, (BytesIO, ReadOnlyFileBuffer)):
|
if self.use_sendfile and not isinstance(buf, (BytesIO, ReadOnlyFileBuffer)):
|
||||||
try:
|
try:
|
||||||
@ -386,9 +386,10 @@ class HTTPConnection(HTTPRequest):
|
|||||||
self.use_sendfile = self.ready = False
|
self.use_sendfile = self.ready = False
|
||||||
raise IOError('sendfile() failed to write any bytes to the socket')
|
raise IOError('sendfile() failed to write any bytes to the socket')
|
||||||
else:
|
else:
|
||||||
sent = self.send(buf.read(min(limit, self.send_bufsize)))
|
data = buf.read(min(limit, self.send_bufsize))
|
||||||
|
sent = self.send(data)
|
||||||
buf.seek(pos + sent)
|
buf.seek(pos + sent)
|
||||||
return buf.tell() == end
|
return buf.tell() >= end
|
||||||
|
|
||||||
def simple_response(self, status_code, msg='', close_after_response=True, extra_headers=None):
|
def simple_response(self, status_code, msg='', close_after_response=True, extra_headers=None):
|
||||||
if self.response_protocol is HTTP1:
|
if self.response_protocol is HTTP1:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user