File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -448,4 +448,17 @@ public function reset_state() {
448
448
$ this ->header = array ();
449
449
$ this ->response = array ();
450
450
}
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
+ }
451
464
}
Original file line number Diff line number Diff line change @@ -546,9 +546,10 @@ public function log_out() {
546
546
*
547
547
* @param string $url The URL to request
548
548
* @param array $options
549
+ * @param mixed $acceptheader mimetype (as string) or false to skip sending an accept header.
549
550
* @return bool
550
551
*/
551
- protected function request ($ url , $ options = array ()) {
552
+ protected function request ($ url , $ options = array (), $ acceptheader = ' application/json ' ) {
552
553
$ murl = new moodle_url ($ url );
553
554
554
555
if ($ this ->accesstoken ) {
@@ -561,7 +562,9 @@ protected function request($url, $options = array()) {
561
562
}
562
563
563
564
// Force JSON format content in response.
564
- $ this ->setHeader ('Accept: application/json ' );
565
+ if ($ acceptheader ) {
566
+ $ this ->setHeader ('Accept: ' . $ acceptheader );
567
+ }
565
568
566
569
return parent ::request ($ murl ->out (false ), $ options );
567
570
}
You can’t perform that action at this time.
0 commit comments