Skip to content

Commit 278d1f7

Browse files
committed
Set a default content-type for POST & PUT methods, if none was given.
It should also fix #19 @todo[gtl]: split request method
1 parent 38fa7c4 commit 278d1f7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Bitbucket/API/Http/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ public function request($endpoint, $params = array(), $method = 'GET', array $he
182182
$endpoint .= (strpos($endpoint, '?') === false ? '?' : '&').'format='.$this->getResponseFormat();
183183
}
184184

185+
// add a default content-type if none was set
186+
if (in_array(strtoupper($method), array('POST', 'PUT')) && empty($headers['Content-Type'])) {
187+
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
188+
}
189+
185190
$request = $this->createRequest($method, $endpoint);
186191

187192
if (!empty($headers)) {

0 commit comments

Comments
 (0)