MDL-60733 core: B/C for google_oauth

The google_oauth class extends oauth2client which was modified to send "Accept" headers.

The "Accept" headers break picasa and could break any other plugin that was using google_oauth.
This commit is contained in:
Damyon Wiese
2017-11-08 15:25:37 +08:00
parent 14f2ce60a7
commit 306a3eba3f
2 changed files with 18 additions and 2 deletions
+13
View File
@@ -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);
}
}
+5 -2
View File
@@ -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);
}