diff --git a/lib/googleapi.php b/lib/googleapi.php index 1c2be1d99f9..19fba45d10d 100644 --- a/lib/googleapi.php +++ b/lib/googleapi.php @@ -448,4 +448,17 @@ class google_oauth extends oauth2_client { $this->header = array(); $this->response = array(); } + + /** + * Make a HTTP request, we override the parents because we do not + * want to send accept headers (this was a change in the parent class and we want to keep the old behaviour). + * + * @param string $url The URL to request + * @param array $options + * @param mixed $acceptheader Not used. + * @return bool + */ + protected function request($url, $options = array(), $acceptheader = 'application/json') { + return parent::request($url, $options, false); + } } diff --git a/lib/oauthlib.php b/lib/oauthlib.php index 7b7262f681d..3c8cffe7fa8 100644 --- a/lib/oauthlib.php +++ b/lib/oauthlib.php @@ -546,9 +546,10 @@ abstract class oauth2_client extends curl { * * @param string $url The URL to request * @param array $options + * @param mixed $acceptheader mimetype (as string) or false to skip sending an accept header. * @return bool */ - protected function request($url, $options = array()) { + protected function request($url, $options = array(), $acceptheader = 'application/json') { $murl = new moodle_url($url); if ($this->accesstoken) { @@ -561,7 +562,9 @@ abstract class oauth2_client extends curl { } // Force JSON format content in response. - $this->setHeader('Accept: application/json'); + if ($acceptheader) { + $this->setHeader('Accept: ' . $acceptheader); + } return parent::request($murl->out(false), $options); }