@@ -57,6 +57,7 @@ class ServerOptions(NamedTuple):
57
57
58
58
59
59
class AIOSocketBodyReader (HTTPBodyReader ):
60
+ """Specialized body reader to work with AIO sockets."""
60
61
61
62
__slots__ = ["socket" , "loop" , "buffer" , "size" ]
62
63
@@ -83,6 +84,7 @@ async def _read(
83
84
84
85
85
86
class AIOSocketBodyWriter (HTTPBodyWriter ):
87
+ """Specialized body writer to work with AIO sockets."""
86
88
87
89
def __init__ (
88
90
self ,
@@ -100,6 +102,8 @@ async def _writeBytes(
100
102
) -> bool :
101
103
if chunk is None or chunk is False :
102
104
pass
105
+ else :
106
+ await self .loop .sock_sendall (self .client , chunk )
103
107
return False
104
108
105
109
async def _writeFile (self , path : Path , size : int = 64_000 ) -> bool :
@@ -260,6 +264,7 @@ async def SendResponse(
260
264
app : Application ,
261
265
writer : HTTPBodyWriter ,
262
266
) -> HTTPResponse | None :
267
+ """Processes the request within the application and sends a response using the given writer."""
263
268
req : HTTPRequest = request
264
269
res : HTTPResponse | None = None
265
270
sent : bool = False
@@ -314,6 +319,7 @@ async def Serve(
314
319
app : Application ,
315
320
options : ServerOptions = ServerOptions (),
316
321
) -> None :
322
+ """Main server coroutine."""
317
323
server = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
318
324
server .setsockopt (socket .SOL_SOCKET , socket .SO_REUSEADDR , 1 )
319
325
server .setsockopt (socket .IPPROTO_TCP , socket .TCP_NODELAY , 1 )
0 commit comments