PHP Class Restagent\Request

For full disclosure this is a shameless rip-off from: https://github.com/inadarei/settee/blob/master/src/classes/ZaphpaRestClient.class.php That is: if you can call "stealing" from one's self "shameless" :)
Show file Open project: zaphpa/zaphpa

Public Methods

Method Description
__construct ( null $base_url = '' ) Public constructor
__destruct ( ) Class destructor cleans up any resources
content_mime_type ( $content ) : void
data ( ) Set a variable (query param or a data var)
delete ( $uri ) HTTP DELETE
file_mime_type ( $path ) : void
get ( $uri ) HTTP GET
head ( $uri ) HTTP HEAD
header ( ) Set an HTTP Head
method ( $method ) : Request Set HTTP method to use with send()
param ( ) Set a query param. This method can/should not be used with HTTP GET! Use var() call instead or you will get an exception
post ( $uri ) HTTP POST
put ( $uri ) HTTP PUT
send ( $uri ) Custom HTTP Method. Use with caution.
timeout ( $ms ) Set curl/http timeout in milliseconds.

Private Methods

Method Description
_http_parse_headers ( $header ) : array Backup PHP impl. for when PECL http_parse_headers() function is not available
check_status ( $response, $full_url ) Check http status for safe return codes
get_full_url ( $uri ) Get full URL from a partial one
http_request ( $http_method, $uri, array $data = [] ) Generic implementation of a HTTP Request.

Method Details

__construct() public method

Public constructor
public __construct ( null $base_url = '' )
$base_url null

__destruct() public method

Class destructor cleans up any resources
public __destruct ( )

content_mime_type() public method

public content_mime_type ( $content ) : void
$content content of a file in a string buffer format.
return void

data() public method

Set a variable (query param or a data var)
public data ( )

delete() public method

HTTP DELETE
public delete ( $uri )

file_mime_type() public method

public file_mime_type ( $path ) : void
$path Full path to a file (e.g. as returned by PHP's realpath function).
return void

get() public method

HTTP GET
public get ( $uri )

head() public method

HTTP HEAD
public head ( $uri )

header() public method

Set an HTTP Head
public header ( )

method() public method

Set HTTP method to use with send()
public method ( $method ) : Request
$method
return Request

param() public method

Set a query param. This method can/should not be used with HTTP GET! Use var() call instead or you will get an exception
public param ( )

post() public method

HTTP POST
public post ( $uri )

put() public method

HTTP PUT
public put ( $uri )

send() public method

Custom HTTP Method. Use with caution.
public send ( $uri )
$uri

timeout() public method

Set curl/http timeout in milliseconds.
public timeout ( $ms )
$ms