Refactor keep_alive
This commit is contained in:
parent
e5fdc7fdd0
commit
7fe418d1b7
|
@ -89,6 +89,10 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
self._last_request_time = None
|
self._last_request_time = None
|
||||||
self._request_handler_task = None
|
self._request_handler_task = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def keep_alive(self):
|
||||||
|
return self.parser.should_keep_alive() and not self.signal.stopped
|
||||||
|
|
||||||
# -------------------------------------------- #
|
# -------------------------------------------- #
|
||||||
# Connection
|
# Connection
|
||||||
# -------------------------------------------- #
|
# -------------------------------------------- #
|
||||||
|
@ -182,9 +186,7 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
Writes response content synchronously to the transport.
|
Writes response content synchronously to the transport.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
keep_alive = (
|
keep_alive = self.keep_alive
|
||||||
self.parser.should_keep_alive() and not self.signal.stopped)
|
|
||||||
|
|
||||||
self.transport.write(
|
self.transport.write(
|
||||||
response.output(
|
response.output(
|
||||||
self.request.version, keep_alive,
|
self.request.version, keep_alive,
|
||||||
|
@ -218,9 +220,7 @@ class HttpProtocol(asyncio.Protocol):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
keep_alive = (
|
keep_alive = self.keep_alive
|
||||||
self.parser.should_keep_alive() and not self.signal.stopped)
|
|
||||||
|
|
||||||
response.transport = self.transport
|
response.transport = self.transport
|
||||||
await response.stream(
|
await response.stream(
|
||||||
self.request.version, keep_alive, self.request_timeout)
|
self.request.version, keep_alive, self.request_timeout)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user