diff options
author | Elmer Thomas <elmer@thinkingserious.com> | 2016-06-10 17:47:24 -0700 |
---|---|---|
committer | Elmer Thomas <elmer@thinkingserious.com> | 2016-06-10 17:47:24 -0700 |
commit | 01c3fc4b94df008cfe03ffb467d4c6dbe6dcfb2c (patch) | |
tree | 19c7727d4e826daca2f9ebe40aca4f99fa4135db /lib | |
parent | b57fed080d8e1ddec91b9a5ab50ad6faf8da8624 (diff) | |
download | php-http-client-01c3fc4b94df008cfe03ffb467d4c6dbe6dcfb2c.zip php-http-client-01c3fc4b94df008cfe03ffb467d4c6dbe6dcfb2c.tar.gz php-http-client-01c3fc4b94df008cfe03ffb467d4c6dbe6dcfb2c.tar.bz2 |
Version Bump v3.1.0: Automatically add Content-Type: application/json when there is a request bodyv3.1.0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/SendGrid/Client.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/SendGrid/Client.php b/lib/SendGrid/Client.php index 860501c..e1fbad6 100644 --- a/lib/SendGrid/Client.php +++ b/lib/SendGrid/Client.php @@ -165,13 +165,15 @@ class Client curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($method)); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); + if(isset($request_headers)) { + $this->request_headers = array_merge($this->request_headers, $request_headers); + } if(isset($request_body)) { $request_body = json_encode($request_body); curl_setopt($curl, CURLOPT_POSTFIELDS, $request_body); $content_length = array('Content-Length: ' . strlen($request_body)); - } - if(isset($request_headers)) { - $this->request_headers = array_merge($this->request_headers, $request_headers); + $content_type = array('Content-Type: application/json'); + $this->request_headers = array_merge($this->request_headers, $content_type); } curl_setopt($curl, CURLOPT_HTTPHEADER, $this->request_headers); $curl_response = curl_exec($curl); |