LTI Integration Library  3.1.0
PHP class library for building LTI integrations
HTTPMessage Class Reference

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

Public Member Functions

 __construct ($url, $method='GET', $params=null, $header=null)
 Class constructor. More...
 
 getUrl ()
 Get the target URL for the request. More...
 
 getMethod ()
 Get the HTTP method for the request. More...
 
 send ()
 Send the request to the target URL. More...
 

Static Public Member Functions

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

Data Fields

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

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
Version
3.1.0
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Definition at line 16 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)
mixed$paramsAssociative array of parameter values to be passed or message body (optional, default is none)
string$headerValues to include in the request header (optional, default is none)

Definition at line 97 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
Http\ClientInterface|null The HTTP client

Definition at line 146 of file HTTPMessage.php.

Referenced by HTTPMessage\send().

◆ getMethod()

getMethod ( )

Get the HTTP method for the request.

Returns
string Message method

Definition at line 126 of file HTTPMessage.php.

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

◆ getUrl()

getUrl ( )

Get the target URL for the request.

Returns
string Request URL

Definition at line 116 of file HTTPMessage.php.

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

◆ send()

send ( )

Send the request to the target URL.

Returns
bool True if the request was successful

Definition at line 164 of file HTTPMessage.php.

References HTTPMessage\$ok, and HTTPMessage\getHttpClient().

◆ setHttpClient()

static setHttpClient (   $httpClient = null)
static

Set the HTTP client to use for sending the message.

Parameters
Http\ClientInterface | null$httpClient

Definition at line 136 of file HTTPMessage.php.

Field Documentation

◆ $error

string $error = ''

Error message.

Definition at line 66 of file HTTPMessage.php.

◆ $ok

bool $ok = false

True if message was processed successfully.

Definition at line 24 of file HTTPMessage.php.

Referenced by HTTPMessage\send().

◆ $request

string null $request = null

Request body.

Definition at line 31 of file HTTPMessage.php.

◆ $requestHeaders

string array $requestHeaders = ''

Request headers.

Definition at line 38 of file HTTPMessage.php.

◆ $response

string null $response = null

Response body.

Definition at line 45 of file HTTPMessage.php.

◆ $responseHeaders

string array $responseHeaders = ''

Response headers.

Definition at line 52 of file HTTPMessage.php.

◆ $status

int $status = 0

Status of response (0 if undetermined).

Definition at line 59 of file HTTPMessage.php.


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