Skip to content

Commit

Permalink
Read from request body only after calling requestHeaderStart
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Aug 30, 2023
1 parent 1c50fd7 commit bc24860
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Connection/Internal/Http2ConnectionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,6 @@ public function request(Request $request, Cancellation $cancellation, Stream $st
$this->socket->getRemoteAddress()->toString()
));
}

// TODO: Starting here, it's not retryable

$body = $request->getBody()->getContent();
$chunk = $body->read($cancellation);
} catch (\Throwable $exception) {
throw $this->wrapException($exception, "Request initialization failed");
}
Expand Down Expand Up @@ -987,6 +982,9 @@ public function request(Request $request, Cancellation $cancellation, Stream $st
try {
events()->requestHeaderStart($request, $stream);

$body = $request->getBody()->getContent();
$chunk = $body->read($cancellation);

$headers = $this->hpack->encode($this->generateHeaders($request));
$flag = Http2Parser::END_HEADERS | ($chunk === null ? Http2Parser::END_STREAM : Http2Parser::NO_FLAG);

Expand Down

0 comments on commit bc24860

Please sign in to comment.