Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

(no description)

File Size: 505 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: Google_Http_Request  - X-Ref

HTTP Request to be executed by IO classes. Upon execution, the
responseHttpCode, responseHeaders and responseBody will be filled in.

__construct($url,$method = 'GET',$headers = array()   X-Ref
No description

getBaseComponent()   X-Ref
Misc function that returns the base url component of the $url
used by the OAuth signing class to calculate the base string

return: string The base url component of the $url.

setBaseComponent($baseComponent)   X-Ref
Set the base URL that path and query parameters will be added to.

param: $baseComponent string

enableGzip()   X-Ref
Enable support for gzipped responses with this request.


disableGzip()   X-Ref
Disable support for gzip responses with this request.


canGzip()   X-Ref
Can this request accept a gzip response?

return: bool

getQueryParams()   X-Ref
Misc function that returns an array of the query parameters of the current
url used by the OAuth signing class to calculate the signature

return: array Query parameters in the query string.

setQueryParam($key, $value)   X-Ref
Set a new query parameter.

param: $key - string to set, does not need to be URL encoded
param: $value - string to set, does not need to be URL encoded

getResponseHttpCode()   X-Ref

return: string HTTP Response Code.

setResponseHttpCode($responseHttpCode)   X-Ref

param: int $responseHttpCode HTTP Response Code.

getResponseHeaders()   X-Ref

return: $responseHeaders (array) HTTP Response Headers.

getResponseBody()   X-Ref

return: string HTTP Response Body

setExpectedClass($class)   X-Ref
Set the class the response to this request should expect.

param: $class string the class name

getExpectedClass()   X-Ref
Retrieve the expected class the response should expect.

return: string class name

enableExpectedRaw()   X-Ref
Enable expected raw response


disableExpectedRaw()   X-Ref
Disable expected raw response


getExpectedRaw()   X-Ref
Expected raw response or not.

return: boolean expected raw response

setResponseHeaders($headers)   X-Ref

param: array $headers The HTTP response headers

getResponseHeader($key)   X-Ref

param: string $key
return: array|boolean Returns the requested HTTP header or

setResponseBody($responseBody)   X-Ref

param: string $responseBody The HTTP response body.

getUrl()   X-Ref

return: string $url The request URL.

getRequestMethod()   X-Ref

return: string $method HTTP Request Method.

getRequestHeaders()   X-Ref

return: array $headers HTTP Request Headers.

getRequestHeader($key)   X-Ref

param: string $key
return: array|boolean Returns the requested HTTP header or

getPostBody()   X-Ref

return: string $postBody HTTP Request Body.

setUrl($url)   X-Ref

param: string $url the url to set

setRequestMethod($method)   X-Ref

param: string $method Set he HTTP Method and normalize

setRequestHeaders($headers)   X-Ref

param: array $headers The HTTP request headers

setPostBody($postBody)   X-Ref

param: string $postBody the postBody to set

setUserAgent($userAgent)   X-Ref
Set the User-Agent Header.

param: string $userAgent The User-Agent.

getUserAgent()   X-Ref

return: string The User-Agent.

getCacheKey()   X-Ref
Returns a cache key depending on if this was an OAuth signed request
in which case it will use the non-signed url and access key to make this
cache key unique per authenticated user, else use the plain request url

return: string The md5 hash of the request cache key.

getParsedCacheControl()   X-Ref
No description

toBatchString($id)   X-Ref

param: string $id
return: string A string representation of the HTTP Request.

parseQuery($string)   X-Ref
Our own version of parse_str that allows for multiple variables
with the same name.

param: $string - the query string to parse

buildQuery($parts)   X-Ref
A version of build query that allows for multiple
duplicate keys.

param: $parts array of key value pairs

maybeMoveParametersToBody()   X-Ref
If we're POSTing and have no body to send, we can send the query
parameters in there, which avoids length issues with longer query
params.