Skip to content

Commit

Permalink
Change headers before applying curl options
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Delcroix committed Feb 14, 2017
1 parent b0bbd2f commit 18c6d67
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/CALLR/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ public function send(
/* curl */
$c = curl_init($url);

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_FAILONERROR, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($c, CURLOPT_FORBID_REUSE, false);

if ($auth instanceof AuthenticationInterface) {
$headers += array_values($auth->getHeaders());
$headers = array_merge($headers, array_values($auth->getHeaders()));
$auth->applyCurlOptions($c);
} elseif (!empty($auth)) {
trigger_error('Using a string for auth is deprecated, use a proper Authenticator instead', E_USER_DEPRECATED);
curl_setopt($c, CURLOPT_USERPWD, $auth);
}

curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_FAILONERROR, true);
curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($c, CURLOPT_FORBID_REUSE, false);

if (is_string($proxy)) {
curl_setopt($c, CURLOPT_PROXY, $proxy);
}
Expand Down

0 comments on commit 18c6d67

Please sign in to comment.