Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
moodle_google_curlio Class Reference

Class moodle_google_curlio. More...

Inheritance diagram for moodle_google_curlio:
Google_IO_Curl Google_IO_Abstract

Public Member Functions

 executeRequest (Google_Http_Request $request)
 Execute an API request.
 
 get_option_name_from_constant ($constant)
 Return the name of an option based on the constant value.
 
 getCachedRequest (Google_Http_Request $request)
 @visible for testing.
 
 getHttpResponseHeaders ($rawHeaders)
 Parse out headers from raw headers.
 
 getTimeout ()
 Get the maximum request time in seconds.
 
 makeRequest (Google_Http_Request $request)
 Execute an HTTP Request.
 
 parseHttpResponse ($respData, $headerSize)
 Used by the IO lib and also the batch processing.
 
 processEntityRequest (Google_Http_Request $request)
 @visible for testing Process an http request that contains an enclosed entity.
 
 setCachedRequest (Google_Http_Request $request)
 @visible for testing.
 
 setOptions ($optparams)
 Set curl options.
 
 setTimeout ($timeout)
 Set the maximum request time in seconds.
 

Public Attributes

const FORM_URLENCODED = 'application/x-www-form-urlencoded'
 
const NO_QUIRK_VERSION = 0x071E00
 
const UNKNOWN_CODE = 0
 

Protected Member Functions

 checkMustRevalidateCachedRequest ($cached, $request)
 Check if an already cached request must be revalidated, and if so update the request with the correct ETag headers.
 
 needsQuirk ()
 Test for the presence of a cURL header processing bug.
 
 updateCachedRequest ($cached, $responseHeaders)
 Update a cached request, using the headers from the last response.
 

Protected Attributes

Google_Client $client
 

Detailed Description

Class moodle_google_curlio.

The initial purpose of this class is to add support for our class curl in Google_IO_Curl. It mostly entirely overrides it.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ checkMustRevalidateCachedRequest()

Google_IO_Abstract::checkMustRevalidateCachedRequest ( $cached,
$request )
protectedinherited

Check if an already cached request must be revalidated, and if so update the request with the correct ETag headers.

Parameters
Google_Http_Request$cachedA previously cached response.
Google_Http_Request$requestThe outbound request. return bool If the cached object needs to be revalidated, false if it is still current and can be re-used.

◆ executeRequest()

moodle_google_curlio::executeRequest ( Google_Http_Request $request)

Execute an API request.

This is a copy/paste from the parent class that uses Moodle's implementation of curl. Portions have been removed or altered.

Parameters
Google_Http_Request$requestthe http request to be executed
Return values
Google_Http_Requesthttp request with the response http code, response headers and response body filled in
Exceptions
Google_IO_Exceptionon curl or IO error

Reimplemented from Google_IO_Curl.

◆ get_option_name_from_constant()

moodle_google_curlio::get_option_name_from_constant ( $constant)

Return the name of an option based on the constant value.

Parameters
int$constantvalue of a CURL constant.
Return values
stringname of the constant if found, or throws exception.
Exceptions
coding_exceptionwhen the constant is not found.
Since
Moodle 2.5

◆ getCachedRequest()

Google_IO_Abstract::getCachedRequest ( Google_Http_Request $request)
inherited

@visible for testing.

Parameters
Google_Http_Request$request
Return values
Google_Http_Request|boolReturns the cached object or false if the operation was unsuccessful.

◆ getHttpResponseHeaders()

Google_IO_Abstract::getHttpResponseHeaders ( $rawHeaders)
inherited

Parse out headers from raw headers.

Parameters
rawHeadersarray or string
Return values
array

◆ getTimeout()

moodle_google_curlio::getTimeout ( )

Get the maximum request time in seconds.

Overridden to use the right option key.

Return values
timeoutin seconds.

Reimplemented from Google_IO_Curl.

◆ makeRequest()

Google_IO_Abstract::makeRequest ( Google_Http_Request $request)
inherited

Execute an HTTP Request.

Parameters
Google_Http_Request$requestthe http request to be executed
Return values
Google_Http_Requesthttp request with the response http code, response headers and response body filled in
Exceptions
Google_IO_Exceptionon curl or IO error

◆ needsQuirk()

Google_IO_Curl::needsQuirk ( )
protectedinherited

Test for the presence of a cURL header processing bug.

Test for the presence of a cURL header processing bug.The cURL bug was present in versions prior to 7.30.0 and caused the header length to be miscalculated when a "Connection established" header added by some proxies was present.

Return values
boolean

Return values
boolean

Reimplemented from Google_IO_Abstract.

◆ parseHttpResponse()

Google_IO_Abstract::parseHttpResponse ( $respData,
$headerSize )
inherited

Used by the IO lib and also the batch processing.

Parameters
$respData
$headerSize
Return values
array

◆ processEntityRequest()

Google_IO_Abstract::processEntityRequest ( Google_Http_Request $request)
inherited

@visible for testing Process an http request that contains an enclosed entity.

Parameters
Google_Http_Request$request
Return values
Google_Http_RequestProcessed request with the enclosed entity.

◆ setCachedRequest()

Google_IO_Abstract::setCachedRequest ( Google_Http_Request $request)
inherited

@visible for testing.

Cache the response to an HTTP request if it is cacheable.

Parameters
Google_Http_Request$request
Return values
boolReturns true if the insertion was successful. Otherwise, return false.

◆ setOptions()

moodle_google_curlio::setOptions ( $optparams)

Set curl options.

We overwrite this method to ensure that the data passed meets the requirement of our curl implementation and so that the keys are strings, and not curl constants.

Parameters
array$optparamsMultiple options used by a cURL session.
Return values
void

Reimplemented from Google_IO_Curl.

◆ setTimeout()

moodle_google_curlio::setTimeout ( $timeout)

Set the maximum request time in seconds.

Overridden to use the right option key.

Parameters
$timeoutin seconds

Reimplemented from Google_IO_Curl.

◆ updateCachedRequest()

Google_IO_Abstract::updateCachedRequest ( $cached,
$responseHeaders )
protectedinherited

Update a cached request, using the headers from the last response.

Parameters
Google_Http_Request$cachedA previously cached response.
mixedAssociative array of response headers from the last request.

The documentation for this class was generated from the following file: