@@ -53,14 +53,14 @@ def route_func(request):
53
53
54
54
response = HTTPResponse(request, content_type="text/plain", chunked=True)
55
55
with response:
56
- response.send_body_chunk ("Some content")
57
- response.send_body_chunk ("Some more content")
56
+ response.send_chunk ("Some content")
57
+ response.send_chunk ("Some more content")
58
58
59
59
# or
60
60
61
61
with HTTPResponse(request, content_type="text/plain", chunked=True) as response:
62
- response.send_body_chunk ("Some content")
63
- response.send_body_chunk ("Some more content")
62
+ response.send_chunk ("Some content")
63
+ response.send_chunk ("Some more content")
64
64
"""
65
65
66
66
request : HTTPRequest
@@ -88,7 +88,7 @@ def __init__( # pylint: disable=too-many-arguments
88
88
89
89
To send the response, call `send` or `send_file`.
90
90
For chunked response use
91
- ``with HTTPRequest(request, content_type=..., chunked=True) as r:`` and `send_chunk_body `.
91
+ ``with HTTPRequest(request, content_type=..., chunked=True) as r:`` and `send_chunk `.
92
92
"""
93
93
self .request = request
94
94
self .status = status if isinstance (status , HTTPStatus ) else HTTPStatus (* status )
@@ -136,7 +136,7 @@ def send(
136
136
content_type : str = None ,
137
137
) -> None :
138
138
"""
139
- Sends response with `body` over the given socket .
139
+ Sends response with content built from ``body`` .
140
140
Implicitly calls ``_send_headers`` before sending the body.
141
141
142
142
Should be called **only once** per response.
@@ -155,7 +155,7 @@ def send_file(
155
155
root_path : str = "./" ,
156
156
) -> None :
157
157
"""
158
- Send response with content of ``filename`` located in ``root_path`` over the given socket .
158
+ Send response with content of ``filename`` located in ``root_path``.
159
159
Implicitly calls ``_send_headers`` before sending the file content.
160
160
161
161
Should be called **only once** per response.
@@ -178,9 +178,9 @@ def send_file(
178
178
while bytes_read := file .read (2048 ):
179
179
self ._send_bytes (self .request .connection , bytes_read )
180
180
181
- def send_chunk_body (self , chunk : str = "" ) -> None :
181
+ def send_chunk (self , chunk : str = "" ) -> None :
182
182
"""
183
- Send chunk of data to the given socket .
183
+ Sends chunk of response .
184
184
185
185
Should be used **only** inside
186
186
``with HTTPResponse(request, chunked=True) as response:`` context manager.
@@ -200,7 +200,7 @@ def __enter__(self):
200
200
201
201
def __exit__ (self , * args , ** kwargs ):
202
202
if self .chunked :
203
- self .send_chunk_body ("" )
203
+ self .send_chunk ("" )
204
204
return True
205
205
206
206
@staticmethod
0 commit comments