@@ -282,6 +282,24 @@ protected static function buildOptions($options, $method, $debug)
282282 return $ options ;
283283 }
284284
285+ /**
286+ * Get the X-Request-Id of the request from the given headers.
287+ *
288+ * @param array<string, array<string>> $headers The headers to check
289+ *
290+ * @return string
291+ */
292+ public static function httpRequestId ($ headers )
293+ {
294+ $ xRequestId = $ headers ['X-Request-Id ' ] ?? '' ;
295+
296+ if (is_string ($ xRequestId )) {
297+ return '' ;
298+ }
299+
300+ return implode (', ' , $ xRequestId );
301+ }
302+
285303 /**
286304 * @param string $url
287305 * @param array $options
@@ -329,17 +347,17 @@ protected static function buildHeaders($url, $options)
329347 /**
330348 * Log if the HTTP code is a 4XX or 5XX error code.
331349 *
332- * @param int $httpCode The HTTP code of the request
333- * @param string $url The URL of the request, for logging
334- * @param array<string, string> $headers The headers of the response
350+ * @param int $httpCode The HTTP code of the request
351+ * @param string $url The URL of the request, for logging
352+ * @param array<string, array< string> > $headers The headers of the response
335353 */
336354 protected static function logRequestIfError ($ httpCode , $ url , $ headers = array ())
337355 {
338356 if ($ httpCode < 400 ) {
339357 return ;
340358 }
341359
342- $ xRequestId = $ headers[ ' X-Request-Id ' ] ?? '' ;
360+ $ xRequestId = self :: httpRequestId ( $ headers) ;
343361
344362 $ lizmapAdmin = 'An HTTP request ended with an error, please check the main error log. ' ;
345363 $ lizmapAdmin .= ' HTTP code ' .$ httpCode .'. ' ;
0 commit comments