@@ -581,7 +581,7 @@ public function head(string $url, $query = null)
581
581
* @param array $data
582
582
* @return \Illuminate\Http\Client\Response
583
583
*/
584
- public function post (string $ url , array $ data = [])
584
+ public function post (string $ url , $ data = [])
585
585
{
586
586
return $ this ->send ('POST ' , $ url , [
587
587
$ this ->bodyFormat => $ data ,
@@ -661,24 +661,10 @@ public function pool(callable $callback)
661
661
*/
662
662
public function send (string $ method , string $ url , array $ options = [])
663
663
{
664
+ $ options = $ this ->parseHttpOptions ($ options );
665
+
664
666
$ url = ltrim (rtrim ($ this ->baseUrl , '/ ' ).'/ ' .ltrim ($ url , '/ ' ), '/ ' );
665
667
666
- if (isset ($ options [$ this ->bodyFormat ])) {
667
- if ($ this ->bodyFormat === 'multipart ' ) {
668
- $ options [$ this ->bodyFormat ] = $ this ->parseMultipartBodyFormat ($ options [$ this ->bodyFormat ]);
669
- } elseif ($ this ->bodyFormat === 'body ' ) {
670
- $ options [$ this ->bodyFormat ] = $ this ->pendingBody ;
671
- }
672
-
673
- if (is_array ($ options [$ this ->bodyFormat ])) {
674
- $ options [$ this ->bodyFormat ] = array_merge (
675
- $ options [$ this ->bodyFormat ], $ this ->pendingFiles
676
- );
677
- }
678
- } else {
679
- $ options [$ this ->bodyFormat ] = $ this ->pendingBody ;
680
- }
681
-
682
668
[$ this ->pendingBody , $ this ->pendingFiles ] = [null , []];
683
669
684
670
if ($ this ->async ) {
@@ -704,6 +690,33 @@ public function send(string $method, string $url, array $options = [])
704
690
}, $ this ->retryDelay ?? 100 , $ this ->retryWhenCallback );
705
691
}
706
692
693
+ /**
694
+ * Parse the HTTP options.
695
+ *
696
+ * @param array $options
697
+ * @return array|array[]
698
+ */
699
+ protected function parseHttpOptions (array $ options )
700
+ {
701
+ if (isset ($ options [$ this ->bodyFormat ])) {
702
+ if ($ this ->bodyFormat === 'multipart ' ) {
703
+ $ options [$ this ->bodyFormat ] = $ this ->parseMultipartBodyFormat ($ options [$ this ->bodyFormat ]);
704
+ } elseif ($ this ->bodyFormat === 'body ' ) {
705
+ $ options [$ this ->bodyFormat ] = $ this ->pendingBody ;
706
+ }
707
+
708
+ if (is_array ($ options [$ this ->bodyFormat ])) {
709
+ $ options [$ this ->bodyFormat ] = array_merge (
710
+ $ options [$ this ->bodyFormat ], $ this ->pendingFiles
711
+ );
712
+ }
713
+ } else {
714
+ $ options [$ this ->bodyFormat ] = $ this ->pendingBody ;
715
+ }
716
+
717
+ return collect ($ options )->toArray ();
718
+ }
719
+
707
720
/**
708
721
* Parse multi-part form data.
709
722
*
0 commit comments