PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/ai/http-request/application/response-parser.php +27 -1 27.528.5 View file →
@@ -35,9 +35,35 @@
35 35 }
36 36 }
37 37 }
38 38
39 - return new Response( $response['body'], $response_code, $response_message, $error_code, $missing_licenses );
39 + $headers = $this->normalize_headers( \wp_remote_retrieve_headers( $response ) );
40 +
41 + return new Response( $response['body'], $response_code, $response_message, $error_code, $missing_licenses, $headers );
42 + }
43 +
44 + /**
45 + * Normalizes wp_remote_retrieve_headers() output to a plain array keyed by lower-cased header name.
46 + *
47 + * @param object|array<string, string|array<string>>|string $raw_headers The raw return value of wp_remote_retrieve_headers(), which is a Requests_Utility_CaseInsensitiveDictionary, an array, or empty string.
48 + *
49 + * @return array<string, string|array<string>> The normalized headers.
50 + */
51 + private function normalize_headers( $raw_headers ): array {
52 + // wp_remote_retrieve_headers() returns a CaseInsensitiveDictionary in WP core; getAll() yields a plain array.
53 + if ( \is_object( $raw_headers ) && \method_exists( $raw_headers, 'getAll' ) ) {
54 + $raw_headers = $raw_headers->getAll();
55 + }
56 + if ( ! \is_array( $raw_headers ) ) {
57 + return [];
58 + }
59 +
60 + $normalized = [];
61 + foreach ( $raw_headers as $name => $value ) {
62 + $normalized[ \strtolower( (string) $name ) ] = $value;
63 + }
64 +
65 + return $normalized;
40 66 }
41 67
42 68 /**
43 69 * Maps the error message to a code.