LTI Integration Library 5.0.0-rc2
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.
 
string getUrl ()
 Get the target URL for the request.
 
string getMethod ()
 Get the HTTP method for the request.
 
bool send ()
 Send the request to the target URL.
 
bool hasRelativeLink ($rel)
 Check whether a relative link of the specified type exists.
 
string null getRelativeLink ($rel)
 Get the URL from the relative link with the specified type.
 
array getRelativeLinks ()
 Get the relative links.
 

Static Public Member Functions

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

Public Attributes

bool $ok = false
 True if message was processed successfully.
 
string null $request = null
 Request body.
 
string array $requestHeaders = ''
 Request headers.
 
string null $response = null
 Response body.
 
string array $responseHeaders = ''
 Response headers.
 
array $relativeLinks = array()
 Relative links in response headers.
 
int $status = 0
 Status of response (0 if undetermined).
 
string $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

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)

Reimplemented in HTTPMessage.

Member Function Documentation

◆ getHttpClient()

static ClientInterface null 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

References Util\logDebug().

◆ getMethod()

string getMethod ( )

Get the HTTP method for the request.

Returns
string Message method

Referenced by StreamClient\send().

◆ getRelativeLink()

string null 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

◆ getRelativeLinks()

array getRelativeLinks ( )

Get the relative links.

Returns
array Associative array of relative links

◆ getUrl()

string getUrl ( )

Get the target URL for the request.

Returns
string Request URL

Referenced by StreamClient\send().

◆ hasRelativeLink()

bool hasRelativeLink (   $rel)

Check whether a relative link of the specified type exists.

Parameters
string$rel
Returns
bool True if it exists

◆ send()

bool send ( )

Send the request to the target URL.

Returns
bool True if the request was successful

◆ setHttpClient()

static void setHttpClient (   $httpClient = null)
static

Set the HTTP client to use for sending the message.

Parameters
ClientInterface | null$httpClient
Returns
void

Member Data Documentation

◆ $error

string $error = ''

Error message.

$error

◆ $ok

bool $ok = false

True if message was processed successfully.

$ok

◆ $relativeLinks

array $relativeLinks = array()

Relative links in response headers.

$relativeLinks

◆ $request

string null $request = null

Request body.

$request

◆ $requestHeaders

string array $requestHeaders = ''

Request headers.

$requestHeaders

◆ $response

string null $response = null

Response body.

$response

◆ $responseHeaders

string array $responseHeaders = ''

Response headers.

$responseHeaders

◆ $status

int $status = 0

Status of response (0 if undetermined).

$status


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