File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 8
8
"""
9
9
10
10
try :
11
- from typing import Dict , Tuple , Union
11
+ from typing import Dict , Tuple , Union , TYPE_CHECKING
12
12
from socket import socket
13
13
from socketpool import SocketPool
14
+
15
+ if TYPE_CHECKING :
16
+ from .server import Server
14
17
except ImportError :
15
18
pass
16
19
@@ -23,6 +26,11 @@ class Request:
23
26
It is passed as first argument to all route handlers.
24
27
"""
25
28
29
+ server : "Server"
30
+ """
31
+ Server object that received the request.
32
+ """
33
+
26
34
connection : Union ["SocketPool.Socket" , "socket.socket" ]
27
35
"""
28
36
Socket object used to send and receive data on the connection.
@@ -72,10 +80,12 @@ class Request:
72
80
73
81
def __init__ (
74
82
self ,
83
+ server : "Server" ,
75
84
connection : Union ["SocketPool.Socket" , "socket.socket" ],
76
85
client_address : Tuple [str , int ],
77
86
raw_request : bytes = None ,
78
87
) -> None :
88
+ self .server = server
79
89
self .connection = connection
80
90
self .client_address = client_address
81
91
self .raw_request = raw_request
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ def _receive_request(
132
132
if not header_bytes :
133
133
return None
134
134
135
- request = Request (sock , client_address , header_bytes )
135
+ request = Request (self , sock , client_address , header_bytes )
136
136
137
137
content_length = int (request .headers .get ("Content-Length" , 0 ))
138
138
received_body_bytes = request .body
You can’t perform that action at this time.
0 commit comments