Skip to content

Commit

Permalink
🚿
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Mar 22, 2019
1 parent 0ffc54b commit 51cbf9b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Psr18/CurlHandle.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ protected function initCurlHeaders(array $options):array{
* @return resource cURL handle
*/
public function init(){
$options = $this->initCurlOptions();

$options = $this->initCurlOptions();
$userinfo = $this->request->getUri()->getUserInfo();
$method = $this->request->getMethod();

if(!empty($userinfo)){
$options[\CURLOPT_USERPWD] = $userinfo;
Expand All @@ -211,12 +211,11 @@ public function init(){
/*
* Some HTTP methods cannot have payload:
*
* - GET — cURL will automatically change method to PUT or POST
* - GET — cURL will automatically change the method to PUT or POST
* if we set CURLOPT_UPLOAD or CURLOPT_POSTFIELDS.
* - HEAD — cURL treats HEAD as GET request with a same restrictions.
* - HEAD — cURL treats HEAD as a GET request with same restrictions.
* - TRACE — According to RFC7231: a client MUST NOT send a message body in a TRACE request.
*/
$method = $this->request->getMethod();

if(\in_array($method, ['DELETE', 'PATCH', 'POST', 'PUT'], true)){
$this->setBodyOptions($options);
Expand Down

0 comments on commit 51cbf9b

Please # to comment.