Skip to content

Commit 6463a04

Browse files
author
David Monllao
committed
Merge branch 'MDL-60733-master' of git://github.com/damyon/moodle
2 parents ccf7578 + d3882ea commit 6463a04

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

lib/googleapi.php

+13
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,17 @@ public function reset_state() {
448448
$this->header = array();
449449
$this->response = array();
450450
}
451+
452+
/**
453+
* Make a HTTP request, we override the parents because we do not
454+
* want to send accept headers (this was a change in the parent class and we want to keep the old behaviour).
455+
*
456+
* @param string $url The URL to request
457+
* @param array $options
458+
* @param mixed $acceptheader Not used.
459+
* @return bool
460+
*/
461+
protected function request($url, $options = array(), $acceptheader = 'application/json') {
462+
return parent::request($url, $options, false);
463+
}
451464
}

lib/oauthlib.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,10 @@ public function log_out() {
604604
*
605605
* @param string $url The URL to request
606606
* @param array $options
607+
* @param mixed $acceptheader mimetype (as string) or false to skip sending an accept header.
607608
* @return bool
608609
*/
609-
protected function request($url, $options = array()) {
610+
protected function request($url, $options = array(), $acceptheader = 'application/json') {
610611
$murl = new moodle_url($url);
611612

612613
if ($this->accesstoken) {
@@ -619,7 +620,9 @@ protected function request($url, $options = array()) {
619620
}
620621

621622
// Force JSON format content in response.
622-
$this->setHeader('Accept: application/json');
623+
if ($acceptheader) {
624+
$this->setHeader('Accept: ' . $acceptheader);
625+
}
623626

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

lib/upgrade.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This files describes API changes in core libraries and APIs,
22
information provided here is intended especially for developers.
33

44
=== 3.4 ===
5-
5+
* oauth2_client::request method has an extra parameter to specify the accept header for the response (MDL-60733)
66
* The following functions, previously used (exclusively) by upgrade steps are not available
77
anymore because of the upgrade cleanup performed for this version. See MDL-57432 for more info:
88
- upgrade_mimetypes()

0 commit comments

Comments
 (0)