Blesta Source Documentation

Http extends NetProtocol

Http component that wraps cURL

Table of Contents

Properties

$cookie_file
$curl
$debug_stream
$headers
$options
$persistent_connection
$response_code
$verify_ssl

Methods

__construct() Creates a new NetHttp object, initializes a curl instance
__destruct() Closes the current curl instance, if open
close() Explicitly close the curl instance, if open
debug() Enables debugging, which is sent to the given stream
get() Execute a GET request on the given URL
open() Explicitly open the curl instance, and close any open instance
persistenConnection() Set whether or not this connection should be persistent
post() Execut a POST request on the given URL
request() Processes the request using the given method and URL, with optional urlencoded parameters
responseCode() Fetch the response code for that last request
setCookieFile() Set the cookie file to use for this request
setHeader() Set a header value, appending it to the existing header data
setHeaders() Set an array of headers, overwritting existing header data
setOption() Set the given $option and $value. Accepts CURLOPT_* options.
setTimeout() Set the timeout for the current request
buildOptions() Passes all set options to curl
Properties
private string $cookie_file

The cookie file to use during the request

$curl

private resource $curl

The curl connection

$debug_stream

private resource $debug_stream

The stream to send debugging info, null to disable debugging

$headers

private array<string|int, mixed> $headers = []

An array of headers to sent during the request

$options

private array<string|int, mixed> $options

An array of options to set for this curl connection

$persistent_connection

private bool $persistent_connection = \false

True to enable persistent connections, false to reset the connection for each request

$response_code

private int $response_code

The HTTP response code returned from the last request

$verify_ssl

private bool $verify_ssl = \false

True to verify the SSL cert, false otherwise

Methods

__construct()

Creates a new NetHttp object, initializes a curl instance

public __construct() : mixed

__destruct()

Closes the current curl instance, if open

public __destruct() : mixed

close()

Explicitly close the curl instance, if open

public close() : mixed

debug()

Enables debugging, which is sent to the given stream

public debug(resource $debug_stream) : mixed
Parameters
$debug_stream : resource

The stream to output debugging info to

get()

Execute a GET request on the given URL

public get(string $url[, mixed $params = null ]) : string
Parameters
$url : string

The URL to GET

$params : mixed = null

An array of key/value pairs, or a string of the format key=value&...

Tags
see
NetHttp::responseCode()
Return values
string

The response from the URL

open()

Explicitly open the curl instance, and close any open instance

public open() : mixed

persistenConnection()

Set whether or not this connection should be persistent

public persistenConnection(bool $persist) : mixed
Parameters
$persist : bool

True to persist, false not to.

post()

Execut a POST request on the given URL

public post(string $url[, mixed $params = null ][, array<string|int, mixed> $files = null ]) : string
Parameters
$url : string

The URL to POST to

$params : mixed = null

An array of key/value pairs, or a string of the format key=value&... (optional)

$files : array<string|int, mixed> = null

A multi-dimensional array of files in the format of [0]=>array("name"=>"Name of file", "file"=>"File path")

Tags
see
NetHttp::responseCode()
Return values
string

The response from the URL

request()

Processes the request using the given method and URL, with optional urlencoded parameters

public request(string $method, string $url[, mixed $params = null ]) : string
Parameters
$method : string

The request method (e.g. GET, POST, PUT, DELETE, etc.)

$url : string

The URL to requets

$params : mixed = null

An array of parametes or a URL encoded string of parameters

Tags
see
NetHttp::responseCode()
Return values
string

The response from the URL

responseCode()

Fetch the response code for that last request

public responseCode() : int
Return values
int

The HTTP response code for that last request

setCookieFile()

Set the cookie file to use for this request

public setCookieFile(mixed $cookie_file) : mixed
Parameters
$cookie_file : mixed
Tags
throws
Exception

thrown when the given $cookie_file does not exist

setHeader()

Set a header value, appending it to the existing header data

public setHeader(string $header) : mixed
Parameters
$header : string

Header string of the format "Content Type: text/html"

setHeaders()

Set an array of headers, overwritting existing header data

public setHeaders(array<string|int, mixed> $headers) : mixed
Parameters
$headers : array<string|int, mixed>

Headers of the format array("Content Type: text/html", "...")

setOption()

Set the given $option and $value. Accepts CURLOPT_* options.

public setOption(int $option, string $value[, bool $override = true ]) : mixed
Parameters
$option : int

The CURLOPT_* option to set

$value : string

The value to set

$override : bool = true

True to override the existing value, otherwise will only set the value if not already set

setTimeout()

Set the timeout for the current request

public setTimeout(int $seconds) : mixed
Parameters
$seconds : int

The number of seconds to wait before timing out

buildOptions()

Passes all set options to curl

private buildOptions() : mixed
Tags
see
NetHttp::setOption()
Tags
subpackage

components.net.http

copyright

Copyright (c) 2010, Phillips Data, Inc.

license

http://www.blesta.com/license/ The Blesta License Agreement

link

Blesta


        
On this page

Search results