Verified Commit 19c00882 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Fix off-by-one indexes in Session.headers.insert

parent 26d2b56c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -445,9 +445,11 @@ class HeadersAccessor(AsyncContextManager["HeaderIterator"]):
			case Position(subject="end"):
				index = len(self._table)
			case Before():
				index = self._table.index(position.subject)
			case After():  # pragma: no-branch
				index = self._table.index(position.subject) + 1
			case After():  # pragma: no-branch
				index = self._table.index(position.subject) + 2
			case _:
				raise TypeError("Expect a Position")
		if index >= len(self._table):
			await self._editor.asend(AddHeader(header.name, header.value))
			self._table.append(header)