@@ -113,7 +113,6 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
113113'controller ' =>'n/a ' ,
114114'locale ' =>$ request ->getLocale (),
115115'dotenv_vars ' =>$ dotenvVars ,
116- 'curlCommand ' =>$ this ->getCurlCommand (),
117116 ];
118117
119118if (isset ($ this ->data ['request_headers ' ]['php-auth-pw ' ])) {
@@ -132,6 +131,9 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
132131
133132$ this ->data ['content ' ] =$ content ;
134133
134+
135+ $ this ->data ['curlCommand ' ] =$ this ->computeCurlCommand ($ request );
136+
135137foreach ($ this ->data as $ key =>$ value ) {
136138if (!\is_array ($ value )) {
137139continue ;
@@ -498,38 +500,35 @@ private function parseController(array|object|string|null $controller): array|st
498500return \is_string ($ controller ) ?$ controller :'n/a ' ;
499501 }
500502
501- private function getDataValue (string $ key ):array
502- {
503- return \is_array ($ this ->data [$ key ]) ?$ this ->data [$ key ] :$ this ->data [$ key ]->getValue ();
504- }
505-
506- public function getCurlCommand (): ?string
503+ public function computeCurlCommand (Request $ request ): ?string
507504 {
508- if (!isset ($ this ->data ['method ' ]) || !isset ($ this ->data ['path_info ' ])) {
509- return null ;
510- }
511-
512505$ command = ['curl ' ,'--compressed ' ];
513506
514507// Build the full URL
515- $ scheme =$ this -> data [ ' request_server ' ][ ' HTTPS ' ] ?? false ?'https ' :'http ' ;
516- $ host =$ this -> data [ ' request_server ' ][ ' HTTP_HOST '] ?? $ this -> data [ ' request_server ' ][ ' SERVER_NAME '] ?? 'localhost ' ;
517- $ url =$ scheme .':// ' .$ host .$ this -> data [ ' path_info ' ] ;
508+ $ scheme =$ request -> isSecure () ?'https ' :'http ' ;
509+ $ host =$ request -> server -> get ( ' HTTP_HOST ', $ request -> server -> get ( ' SERVER_NAME ', 'localhost ' )) ;
510+ $ url =$ scheme .':// ' .$ host .$ request -> getRequestUri () ;
518511
519- if (!empty ($ this -> data [ ' request_query ' ] )) {
520- $ url .='? ' .http_build_query ($ this -> getDataValue ( ' request_query ' ));
512+ if (!empty ($ request -> query -> all () )) {
513+ $ url .='? ' .http_build_query ($ request -> query -> all ( ));
521514 }
522515
523516// Add HTTP method
524- $ method =$ this ->data ['method ' ];
525- if (Request::METHOD_GET !==$ method ) {
526- $ command [] =\sprintf ('--request %s ' ,$ method );
517+ $ method =$ request ->getMethod ();
518+ switch ($ method ) {
519+ case Request::METHOD_HEAD :
520+ $ command [] ='--head ' ;
521+ break ;
522+ case Request::METHOD_GET :
523+ break ;
524+ default :
525+ $ command [] =\sprintf ('--request %s ' ,$ method );
527526 }
528527
529528$ command [] =\sprintf ('--url %s ' ,escapeshellarg ($ url ));
530529
531530// Add headers
532- foreach ($ this -> getDataValue ( ' request_headers ' )as $ name =>$ value ) {
531+ foreach ($ request -> headers -> all ( )as $ name =>$ value ) {
533532if (\is_array ($ value )) {
534533$ value =implode (', ' ,$ value );
535534 }
@@ -543,9 +542,9 @@ public function getCurlCommand(): ?string
543542 }
544543
545544// Add cookies
546- if (!empty ($ this -> getDataValue ( ' request_cookies ' ))) {
545+ if (!empty ($ request -> cookies -> all ( ))) {
547546$ cookies = [];
548- foreach ($ this -> getDataValue ( ' request_cookies ' )as $ name =>$ value ) {
547+ foreach ($ request -> cookies -> all ( )as $ name =>$ value ) {
549548$ cookies [] =$ name .'= ' .$ value ;
550549 }
551550$ command [] ='--header ' .escapeshellarg ('Cookie: ' .implode ('; ' ,$ cookies ));
@@ -560,6 +559,11 @@ public function getCurlCommand(): ?string
560559return implode (" \\\n " ,$ command );
561560 }
562561
562+ public function getCurlCommand ():string
563+ {
564+ return $ this ->data ['curlCommand ' ] ??'' ;
565+ }
566+
563567private function escapePayload (string $ payload ):string
564568 {
565569static $ useProcess ;