rex_socket_proxy
extends rex_socket
in package
Class for sockets over a proxy.
Tags
Table of Contents
Properties
- $acceptCompression : bool
- $destinationHost : string
- $destinationPort : int
- $destinationSsl : bool
- $followRedirects : false|int
- $headers : array<string, string>
- $host : string
- $options : array<string|int, mixed>
- $path : string
- $port : int
- $ssl : bool
- $stream : resource
- $timeout : int
Methods
- acceptCompression() : $this
- addBasicAuthorization() : $this
- Adds the basic authorization header to the current request.
- addHeader() : $this
- Adds a header to the current request.
- doDelete() : rex_socket_response
- Makes a DELETE request.
- doGet() : rex_socket_response
- Makes a GET request.
- doPost() : rex_socket_response
- Makes a POST request.
- doRequest() : rex_socket_response
- Makes a request.
- factory() : static
- Factory method.
- factoryUrl() : static
- Creates a socket by a full URL.
- followRedirects() : $this
- Sets number of redirects that should be followed automatically.
- setDestination() : $this
- Sets the destination.
- setDestinationUrl() : $this
- Sets the destination by a full URL.
- setOptions() : $this
- Sets the socket context options.
- setPath() : $this
- Sets the path.
- setTimeout() : $this
- Sets the timeout for the connection.
- __construct() : mixed
- openConnection() : void
- Opens the socket connection.
- parseUrl() : array{host: string, port: int, ssl: bool, path: string}
- Parses a full URL and returns an array with the keys "host", "port", "ssl" and "path".
- writeRequest() : rex_socket_response
- Writes a request to the opened connection.
Properties
$acceptCompression
protected
bool
$acceptCompression
= \false
$destinationHost
protected
string
$destinationHost
$destinationPort
protected
int
$destinationPort
$destinationSsl
protected
bool
$destinationSsl
$followRedirects
protected
false|int
$followRedirects
= \false
$headers
protected
array<string, string>
$headers
= []
$host
protected
string
$host
$options
protected
array<string|int, mixed>
$options
= []
$path
protected
string
$path
= '/'
$port
protected
int
$port
$ssl
protected
bool
$ssl
$stream
protected
resource
$stream
$timeout
protected
int
$timeout
= 15
Methods
acceptCompression()
public
acceptCompression() : $this
Return values
$thisaddBasicAuthorization()
Adds the basic authorization header to the current request.
public
addBasicAuthorization(string $user, string $password) : $this
Parameters
- $user : string
- $password : string
Return values
$this —Current socket
addHeader()
Adds a header to the current request.
public
addHeader(string $key, string $value) : $this
Parameters
- $key : string
- $value : string
Return values
$this —Current socket
doDelete()
Makes a DELETE request.
public
doDelete() : rex_socket_response
Tags
Return values
rex_socket_response —Response
doGet()
Makes a GET request.
public
doGet() : rex_socket_response
Tags
Return values
rex_socket_response —Response
doPost()
Makes a POST request.
public
doPost([mixed $data = '' ][, array<string, array{path: string, type: string}> $files = [] ]) : rex_socket_response
Parameters
- $data : mixed = ''
- $files : array<string, array{path: string, type: string}> = []
-
Files array, e.g.
array('myfile' => array('path' => $path, 'type' => 'image/png'))
Tags
Return values
rex_socket_response —Response
doRequest()
Makes a request.
public
doRequest(string $method[, mixed $data = '' ]) : rex_socket_response
Parameters
- $method : string
-
HTTP method, e.g. "GET"
- $data : mixed = ''
Tags
Return values
rex_socket_response —Response
factory()
Factory method.
public
static factory(string $host[, int $port = 80 ][, bool $ssl = false ]) : static
Parameters
- $host : string
-
Host name
- $port : int = 80
-
Port number
- $ssl : bool = false
-
SSL flag
Tags
Return values
static —Socket instance
factoryUrl()
Creates a socket by a full URL.
public
static factoryUrl(string $url) : static
Parameters
- $url : string
-
URL
Tags
Return values
static —Socket instance
followRedirects()
Sets number of redirects that should be followed automatically.
public
followRedirects(false|int $redirects) : $this
The method only affects GET requests.
Parameters
- $redirects : false|int
-
Number of max redirects
Return values
$this —Current socket
setDestination()
Sets the destination.
public
setDestination(string $host[, int $port = 80 ][, bool $ssl = false ]) : $this
Parameters
- $host : string
-
Host name
- $port : int = 80
-
Port number
- $ssl : bool = false
-
SSL flag
Return values
$this —Current socket
setDestinationUrl()
Sets the destination by a full URL.
public
setDestinationUrl(string $url) : $this
Parameters
- $url : string
-
Full URL
Return values
$this —Current socket
setOptions()
Sets the socket context options.
public
setOptions(array<string|int, mixed> $options) : $this
Available options can be found on https://www.php.net/manual/en/context.php
Parameters
- $options : array<string|int, mixed>
Return values
$this —Current socket
setPath()
Sets the path.
public
setPath(string $path) : $this
Parameters
- $path : string
Return values
$this —Current socket
setTimeout()
Sets the timeout for the connection.
public
setTimeout(int $timeout) : $this
Parameters
- $timeout : int
-
Timeout
Return values
$this —Current socket
__construct()
protected
__construct(string $host[, int $port = 80 ][, bool $ssl = false ]) : mixed
Parameters
- $host : string
-
Host name
- $port : int = 80
-
Port number
- $ssl : bool = false
-
SSL flag
openConnection()
Opens the socket connection.
protected
openConnection() : void
parseUrl()
Parses a full URL and returns an array with the keys "host", "port", "ssl" and "path".
protected
static parseUrl(string $url) : array{host: string, port: int, ssl: bool, path: string}
Parameters
- $url : string
-
Full URL
Tags
Return values
array{host: string, port: int, ssl: bool, path: string} —URL parts
writeRequest()
Writes a request to the opened connection.
protected
writeRequest(string $method, string $path[, array<string, string> $headers = [] ][, mixed $data = '' ]) : rex_socket_response
Parameters
- $method : string
-
HTTP method, e.g. "GET"
- $path : string
-
Path
- $headers : array<string, string> = []
-
Headers
- $data : mixed = ''
Tags
Return values
rex_socket_response —Response