@@ -503,34 +503,28 @@ private function computeCurlCommand(Request $request): ?string
503503 {
504504 $ command = ['curl ' , '--compressed ' ];
505505
506- // Build the full URL
507506 $ scheme = $ request ->isSecure () ? 'https ' : 'http ' ;
508507 $ host = $ request ->server ->get ('HTTP_HOST ' , $ request ->server ->get ('SERVER_NAME ' , 'localhost ' ));
509508 $ url = $ scheme .':// ' .$ host .$ request ->getRequestUri ();
510509
511- if (! empty ( $ request ->query ->all () )) {
510+ if ($ request ->query ->all ()) {
512511 $ url .= '? ' .http_build_query ($ request ->query ->all ());
513512 }
514513
515514 // Add HTTP method
516515 $ method = $ request ->getMethod ();
517- switch ($ method ) {
518- case Request::METHOD_HEAD :
519- $ command [] = '--head ' ;
520- break ;
521- case Request::METHOD_GET :
522- break ;
523- default :
524- $ command [] = \sprintf ('--request %s ' , $ method );
516+
517+ if ($ method === Request::METHOD_HEAD ) {
518+ $ command [] = '--head ' ;
519+ } elseif ($ method !== Request::METHOD_GET ) {
520+ $ command [] = '--request ' .$ method ;
525521 }
526522
527523 $ command [] = \sprintf ('--url %s ' , escapeshellarg ($ url ));
528524
529525 // Add headers
530526 foreach ($ request ->headers ->all () as $ name => $ value ) {
531- if (\is_array ($ value )) {
532- $ value = implode (', ' , $ value );
533- }
527+ $ value = implode (', ' , $ value ?? []);
534528
535529 // Skip certain headers
536530 if (\in_array (strtolower ($ name ), ['host ' , 'cookie ' ])) {
@@ -541,7 +535,7 @@ private function computeCurlCommand(Request $request): ?string
541535 }
542536
543537 // Add cookies
544- if (! empty ( $ request ->cookies ->all () )) {
538+ if ($ request ->cookies ->all ()) {
545539 $ cookies = [];
546540 foreach ($ request ->cookies ->all () as $ name => $ value ) {
547541 $ cookies [] = $ name .'= ' .$ value ;
@@ -551,7 +545,7 @@ private function computeCurlCommand(Request $request): ?string
551545
552546 // Add body data
553547 $ content = $ this ->data ['content ' ];
554- if (! empty ( $ content) && \in_array ($ method , [Request::METHOD_POST , Request::METHOD_PUT , Request::METHOD_PATCH , Request::METHOD_DELETE ])) {
548+ if ($ content && \in_array ($ method , [Request::METHOD_POST , Request::METHOD_PUT , Request::METHOD_PATCH , Request::METHOD_DELETE ])) {
555549 $ command [] = '--data-raw ' .$ this ->escapePayload ($ content );
556550 }
557551
0 commit comments