Skip to content

Commit a5a0873

Browse files
committed
[Fix] server: writer was not sending data
1 parent 81384a7 commit a5a0873

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/py/extra/server.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class ServerOptions(NamedTuple):
5757

5858

5959
class AIOSocketBodyReader(HTTPBodyReader):
60+
"""Specialized body reader to work with AIO sockets."""
6061

6162
__slots__ = ["socket", "loop", "buffer", "size"]
6263

@@ -83,6 +84,7 @@ async def _read(
8384

8485

8586
class AIOSocketBodyWriter(HTTPBodyWriter):
87+
"""Specialized body writer to work with AIO sockets."""
8688

8789
def __init__(
8890
self,
@@ -100,6 +102,8 @@ async def _writeBytes(
100102
) -> bool:
101103
if chunk is None or chunk is False:
102104
pass
105+
else:
106+
await self.loop.sock_sendall(self.client, chunk)
103107
return False
104108

105109
async def _writeFile(self, path: Path, size: int = 64_000) -> bool:
@@ -260,6 +264,7 @@ async def SendResponse(
260264
app: Application,
261265
writer: HTTPBodyWriter,
262266
) -> HTTPResponse | None:
267+
"""Processes the request within the application and sends a response using the given writer."""
263268
req: HTTPRequest = request
264269
res: HTTPResponse | None = None
265270
sent: bool = False
@@ -314,6 +319,7 @@ async def Serve(
314319
app: Application,
315320
options: ServerOptions = ServerOptions(),
316321
) -> None:
322+
"""Main server coroutine."""
317323
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
318324
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
319325
server.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

0 commit comments

Comments
 (0)