Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ shared by `Renderer` and `SsrPublish`. `render()` returns `RenderedEmbed`
hardening. `health()` and `warm()`. `Testing\FakeSsrTransport`.
- PHPStan at max, `composer validate --strict`, `--prefer-lowest` CI,
`failOnDeprecation`. `SECURITY.md`.
- Streams fallback reads `$http_response_header` in the `file_get_contents`
caller (PHP < 8.4). That identifier lives in a class loaded only then, so
PHP 8.5 does not compile the deprecation. `$GLOBALS` is empty there.
- Streams fallback reads the response headers from the stream metadata
(`stream_get_meta_data()`), not `$http_response_header` (deprecated in
PHP 8.5) or `$GLOBALS` (empty there). One code path for PHP 8.2–8.5.

## 0.3.0 — 2026-09-12

Expand Down
27 changes: 0 additions & 27 deletions src/Embed/LegacyHttpStreamFetch.php

This file was deleted.

27 changes: 15 additions & 12 deletions src/Embed/NativeSsrTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,24 @@ private function withStreams(SsrHttpRequest $request): SsrHttpResponse
$http['content'] = $request->body;
}

// PHP 8.5 deprecates the $http_response_header identifier itself.
// Keep that name out of this file; PHP < 8.4 loads a sidecar class.
if (function_exists('http_get_last_response_headers')) {
$body = @file_get_contents($request->url, false, stream_context_create(['http' => $http]));
if ($body === false) {
throw new SsrUnavailable('SSR request failed');
}
// Read the response headers from the stream metadata: PHP 8.5
// deprecates $http_response_header, and http_get_last_response_headers()
// needs PHP 8.4.
$stream = @fopen($request->url, 'rb', false, stream_context_create(['http' => $http]));
if ($stream === false) {
throw new SsrUnavailable('SSR request failed');
}

return $this->responseFromHeaderLines(
$this->stringLines(http_get_last_response_headers()),
$body,
);
try {
$headers = stream_get_meta_data($stream)['wrapper_data'] ?? null;
$body = stream_get_contents($stream);
} finally {
fclose($stream);
}

[$body, $headers] = LegacyHttpStreamFetch::get($request->url, $http);
if ($body === false) {
throw new SsrUnavailable('SSR request failed');
}

return $this->responseFromHeaderLines($this->stringLines($headers), $body);
}
Expand Down
Loading