Skip to content

Commit c222d09

Browse files
committed
Changed send_chunk_body to send_chunk for unification
1 parent a12d4ab commit c222d09

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

adafruit_httpserver/response.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ def route_func(request):
5353
5454
response = HTTPResponse(request, content_type="text/plain", chunked=True)
5555
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")
5858
5959
# or
6060
6161
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")
6464
"""
6565

6666
request: HTTPRequest
@@ -88,7 +88,7 @@ def __init__( # pylint: disable=too-many-arguments
8888
8989
To send the response, call `send` or `send_file`.
9090
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`.
9292
"""
9393
self.request = request
9494
self.status = status if isinstance(status, HTTPStatus) else HTTPStatus(*status)
@@ -136,7 +136,7 @@ def send(
136136
content_type: str = None,
137137
) -> None:
138138
"""
139-
Sends response with `body` over the given socket.
139+
Sends response with content built from ``body``.
140140
Implicitly calls ``_send_headers`` before sending the body.
141141
142142
Should be called **only once** per response.
@@ -155,7 +155,7 @@ def send_file(
155155
root_path: str = "./",
156156
) -> None:
157157
"""
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``.
159159
Implicitly calls ``_send_headers`` before sending the file content.
160160
161161
Should be called **only once** per response.
@@ -178,9 +178,9 @@ def send_file(
178178
while bytes_read := file.read(2048):
179179
self._send_bytes(self.request.connection, bytes_read)
180180

181-
def send_chunk_body(self, chunk: str = "") -> None:
181+
def send_chunk(self, chunk: str = "") -> None:
182182
"""
183-
Send chunk of data to the given socket.
183+
Sends chunk of response.
184184
185185
Should be used **only** inside
186186
``with HTTPResponse(request, chunked=True) as response:`` context manager.
@@ -200,7 +200,7 @@ def __enter__(self):
200200

201201
def __exit__(self, *args, **kwargs):
202202
if self.chunked:
203-
self.send_chunk_body("")
203+
self.send_chunk("")
204204
return True
205205

206206
@staticmethod

0 commit comments

Comments
 (0)