@@ -310,11 +310,14 @@ protected static function buildHeaders($url, $options)
310310 ), $ options ['headers ' ]);
311311
312312 if (strpos ($ url , self ::$ services ->wmsServerURL ) === 0 ) {
313- // headers only for QGIS server
313+ // Headers only for QGIS server
314+ parse_str (parse_url ($ options ['headers ' ]['X-Qgis-Service-Url ' ], PHP_URL_QUERY ), $ output );
315+ $ requestId = $ output ['repository ' ].'- ' .$ output ['project ' ];
316+ $ requestId .= '- ' .uniqid ().'- ' .bin2hex (random_bytes (10 ));
314317 $ options ['headers ' ] = array_merge (
315318 self ::userHttpHeader (),
316319 self ::$ services ->wmsServerHeaders ,
317- array ('X-Request-Id ' => uniqid (). ' - ' . bin2hex ( random_bytes ( 10 )) ),
320+ array ('X-Request-Id ' => $ requestId ),
318321 $ options ['headers ' ]
319322 );
320323 }
@@ -339,7 +342,16 @@ protected static function logRequestIfError($httpCode, $url, $headers = array())
339342 return ;
340343 }
341344
342- $ xRequestId = $ headers ['X-Request-Id ' ] ?? '' ;
345+ if (isset ($ headers ['X-Request-Id ' ])) {
346+ if (is_array ($ headers ['X-Request-Id ' ])) {
347+ $ xRequestId = implode (', ' , $ headers ['X-Request-Id ' ]);
348+ $ xRequestId = json_encode ($ headers ['X-Request-Id ' ]);
349+ } else {
350+ $ xRequestId = $ headers ['X-Request-Id ' ];
351+ }
352+ } else {
353+ $ xRequestId = '' ;
354+ }
343355
344356 $ lizmapAdmin = 'An HTTP request ended with an error, please check the main error log. ' ;
345357 $ lizmapAdmin .= ' HTTP code ' .$ httpCode .'. ' ;
0 commit comments