Verified Commit 1a7cb927 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Continue to collect headers while skipping to the POST phase

parent 6c4557b1
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -371,10 +371,12 @@ class HeadersAccessor(AsyncContextManager["HeaderIterator"]):
		# in an uncoordinated manner; note the broadcaster is locked at this point
		for header in self._table:
			yield header
		seen = set(id(header) for header in self._table)
		while self.session.phase <= Phase.HEADERS:
			match (await self.session.broadcast.receive()):
				case Header() as header:
					self._table.append(header)
					seen.add(id(header))
					try:
						yield header
					except GeneratorExit:
@@ -382,6 +384,12 @@ class HeadersAccessor(AsyncContextManager["HeaderIterator"]):
						raise
				case EndOfHeaders():
					return
		# It's possible for collect() to have been called while yielded, in which case the
		# loop will end. Yield any headers that were stored by collect() but not yet
		# yielded.
		for header in self._table:
			if id(header) not in seen:
				yield header

	async def collect(self) -> None:
		"""
@@ -547,6 +555,9 @@ async def _until_editable(session: Session) -> None:
		return
	session.body.skip = True
	while session.phase < Phase.POST:
		if session.phase == Phase.HEADERS:
			await session.headers.collect()
		else:
			await session.broadcast.receive()