Skip to content

Commit

Permalink
[PR #8846/4dd8c807 backport][3.11] Format status lines with f-strings (
Browse files Browse the repository at this point in the history
…#8869)

Co-authored-by: J. Nick Koston <nick@koston.org>
  • Loading branch information
patchback[bot] and bdraco authored Aug 23, 2024
1 parent a74e4f0 commit 3b3156e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,8 @@ async def send(self, conn: "Connection") -> "ClientResponse":
self.headers[hdrs.CONNECTION] = connection

# status + headers
status_line = "{0} {1} HTTP/{v.major}.{v.minor}".format(
self.method, path, v=self.version
)
v = self.version
status_line = f"{self.method} {path} HTTP/{v.major}.{v.minor}"
await writer.write_headers(status_line, self.headers)
coro = self.write_bytes(writer, conn)

Expand Down
4 changes: 1 addition & 3 deletions aiohttp/web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,7 @@ async def _write_headers(self) -> None:
assert writer is not None
# status line
version = request.version
status_line = "HTTP/{}.{} {} {}".format(
version[0], version[1], self._status, self._reason
)
status_line = f"HTTP/{version[0]}.{version[1]} {self._status} {self._reason}"
await writer.write_headers(status_line, self._headers)

async def write(self, data: bytes) -> None:
Expand Down

0 comments on commit 3b3156e

Please sign in to comment.