Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Licensed to Jasig under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Jasig licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

Author: Adam Franco <afranco@middlebury.edu>
License: http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
File Size: 380 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CAS_Request_AbstractRequest:: (17 methods):
  setUrl()
  addCookie()
  addCookies()
  addHeader()
  addHeaders()
  makePost()
  setPostBody()
  setSslCaCert()
  send()
  storeResponseHeaders()
  storeResponseHeader()
  storeResponseBody()
  storeErrorMessage()
  getResponseHeaders()
  getResponseStatusCode()
  getResponseBody()
  getErrorMessage()


Class: CAS_Request_AbstractRequest  - X-Ref

Provides support for performing web-requests via curl

setUrl($url)   X-Ref
Set the URL of the Request

param: string $url Url to set
return: void

addCookie($name, $value)   X-Ref
Add a cookie to the request.

param: string $name  Name of entry
param: string $value value of entry
return: void

addCookies(array $cookies)   X-Ref
Add an array of cookies to the request.
The cookie array is of the form
array('cookie_name' => 'cookie_value', 'cookie_name2' => cookie_value2')

param: array $cookies cookies to add
return: void

addHeader($header)   X-Ref
Add a header string to the request.

param: string $header Header to add
return: void

addHeaders(array $headers)   X-Ref
Add an array of header strings to the request.

param: array $headers headers to add
return: void

makePost()   X-Ref
Make the request a POST request rather than the default GET request.

return: void

setPostBody($body)   X-Ref
Add a POST body to the request

param: string $body body to add
return: void

setSslCaCert($caCertPath,$validate_cn=true)   X-Ref
Specify the path to an SSL CA certificate to validate the server with.

param: string $caCertPath  path to cert
param: bool   $validate_cn valdiate CN of certificate
return: void

send()   X-Ref
Perform the request.

return: bool TRUE on success, FALSE on failure.

storeResponseHeaders(array $headers)   X-Ref
Store the response headers.

param: array $headers headers to store
return: void

storeResponseHeader($header)   X-Ref
Store a single response header to our array.

param: string $header header to store
return: void

storeResponseBody($body)   X-Ref
Store the response body.

param: string $body body to store
return: void

storeErrorMessage($message)   X-Ref
Add a string to our error message.

param: string $message message to add
return: void

getResponseHeaders()   X-Ref
Answer the headers of the response.

return: array An array of header strings.

getResponseStatusCode()   X-Ref
Answer HTTP status code of the response

return: int

getResponseBody()   X-Ref
Answer the body of response.

return: string

getErrorMessage()   X-Ref
Answer a message describing any errors if the request failed.

return: string