Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'MDL-60733-33' of git://github.com/damyon/moodle into MO…
…ODLE_33_STABLE
  • Loading branch information
David Monllao committed Nov 8, 2017
2 parents 64baebd + c8e7e1c commit 3417cf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions lib/googleapi.php
Expand Up @@ -448,4 +448,17 @@ public function reset_state() {
$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);
}
}
7 changes: 5 additions & 2 deletions lib/oauthlib.php
Expand Up @@ -604,9 +604,10 @@ public function log_out() {
*
* @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) {
Expand All @@ -619,7 +620,9 @@ protected function request($url, $options = array()) {
}

// Force JSON format content in response.
$this->setHeader('Accept: application/json');
if ($acceptheader) {
$this->setHeader('Accept: ' . $acceptheader);
}

$response = parent::request($murl->out(false), $options);

Expand Down

0 comments on commit 3417cf9

Please sign in to comment.