LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
HttpMessage Class Reference

Class to represent an HTTP message request. More...

Inheritance diagram for HttpMessage:
HTTPMessage

Public Member Functions

 __construct ($url, $method='GET', $params=null, $header=null)
 Class constructor.
 
 getUrl ()
 Get the target URL for the request.
 
 getMethod ()
 Get the HTTP method for the request.
 
 send ()
 Send the request to the target URL.
 
 hasRelativeLink ($rel)
 Check whether a relative link of the specified type exists.
 
 getRelativeLink ($rel)
 Get the URL from the relative link with the specified type.
 
 getRelativeLinks ()
 Get the relative links.
 

Static Public Member Functions

static setHttpClient ($httpClient=null)
 Set the HTTP client to use for sending the message.
 
static getHttpClient ()
 Get the HTTP client to use for sending the message.
 

Data Fields

 $ok = false
 True if message was processed successfully.
 
 $request = null
 Request body.
 
 $requestHeaders = ''
 Request headers.
 
 $response = null
 Response body.
 
 $responseHeaders = ''
 Response headers.
 
 $relativeLinks = array()
 Relative links in response headers.
 
 $status = 0
 Status of response (0 if undetermined).
 
 $error = ''
 Error message.
 

Detailed Description

Class to represent an HTTP message request.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Definition at line 14 of file HttpMessage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $url,
  $method = 'GET',
  $params = null,
  $header = null 
)

Class constructor.

Parameters
string$urlURL to send request to
string$methodRequest method to use (optional, default is GET)
array | string | null$paramsAssociative array of parameter values to be passed or message body (optional, default is none)
array | string | null$headerValues to include in the request header (optional, default is none)

Reimplemented in HTTPMessage.

Definition at line 102 of file HttpMessage.php.

Member Function Documentation

◆ getHttpClient()

static getHttpClient ( )
static

Get the HTTP client to use for sending the message.

If one is not set, a default client is created.

Returns
ClientInterface|null The HTTP client

Definition at line 152 of file HttpMessage.php.

References Util\logDebug().

Referenced by HttpMessage\send().

◆ getMethod()

getMethod ( )

Get the HTTP method for the request.

Returns
string Message method

Definition at line 131 of file HttpMessage.php.

Referenced by CurlClient\send(), and StreamClient\send().

◆ getRelativeLink()

getRelativeLink (   $rel)

Get the URL from the relative link with the specified type.

Parameters
string$rel
Returns
string|null The URL associated with the relative link, null if it is not defined

Definition at line 238 of file HttpMessage.php.

References HttpMessage\hasRelativeLink().

◆ getRelativeLinks()

getRelativeLinks ( )

Get the relative links.

Returns
array Associative array of relative links

Definition at line 253 of file HttpMessage.php.

References HttpMessage\$relativeLinks.

◆ getUrl()

getUrl ( )

Get the target URL for the request.

Returns
string Request URL

Definition at line 121 of file HttpMessage.php.

Referenced by CurlClient\send(), and StreamClient\send().

◆ hasRelativeLink()

hasRelativeLink (   $rel)

Check whether a relative link of the specified type exists.

Parameters
string$rel
Returns
bool True if it exists

Definition at line 226 of file HttpMessage.php.

Referenced by HttpMessage\getRelativeLink().

◆ send()

send ( )

Send the request to the target URL.

Returns
bool True if the request was successful

Definition at line 173 of file HttpMessage.php.

References Util\$logLevel, HttpMessage\$ok, HttpMessage\getHttpClient(), Util\logError(), Util\logInfo(), and Util\LOGLEVEL_NONE.

◆ setHttpClient()

static setHttpClient (   $httpClient = null)
static

Set the HTTP client to use for sending the message.

Parameters
ClientInterface | null$httpClient

Definition at line 141 of file HttpMessage.php.

References Util\logDebug().

Field Documentation

◆ $error

string $error = ''

Error message.

Definition at line 71 of file HttpMessage.php.

◆ $ok

bool $ok = false

True if message was processed successfully.

Definition at line 22 of file HttpMessage.php.

Referenced by HttpMessage\send().

◆ $relativeLinks

array $relativeLinks = array()

Relative links in response headers.

Definition at line 57 of file HttpMessage.php.

Referenced by HttpMessage\getRelativeLinks().

◆ $request

string null $request = null

Request body.

Definition at line 29 of file HttpMessage.php.

◆ $requestHeaders

string array $requestHeaders = ''

Request headers.

Definition at line 36 of file HttpMessage.php.

◆ $response

string null $response = null

Response body.

Definition at line 43 of file HttpMessage.php.

◆ $responseHeaders

string array $responseHeaders = ''

Response headers.

Definition at line 50 of file HttpMessage.php.

◆ $status

int $status = 0

Status of response (0 if undetermined).

Definition at line 64 of file HttpMessage.php.


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