File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -53,21 +53,24 @@ public function prepareSend(): CurlRequest
5353 $ ch = $ this ->getCh ();
5454 $ method = $ this ->getMethod ();
5555 $ uri = $ this ->getUri ();
56- // $headers = $this->getHeadersLines();
57- $ body = 'GET ' === $ method ? $ this ->getQuery () : (
58- 'POST ' === $ method
59- ? json_encode ($ this ->getPost ())
60- : $ this ->getBody ()
61- );
56+
6257 // добавляем данные запроса
6358 if ('GET ' === $ method ) {
59+ $ body = $ this ->getQuery ();
6460 $ uri .= static ::prepareDataToUriQuery ($ body );
6561 } else {
62+ $ type = $ this ->getHeader ('Content-Type ' );
63+ if (false !== strpos ($ type , 'application/json ' )) {
64+ $ this ->withBodyJson ($ this ->getBody ());
65+ }
66+ $ body = $ this ->getBody ();
67+
6668 if ('POST ' === $ method ) curl_setopt ($ ch , CURLOPT_POST , 1 );
6769 else curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , $ method );
6870 curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ body );
6971 $ this ->withHeader ('Content-Length ' , mb_strlen ($ body ));
7072 }
73+
7174 // устанавливаем cookie
7275 if (!empty ($ this ->cookies )) {
7376 $ cookies = [];
You can’t perform that action at this time.
0 commit comments