HumHub Documentation (unofficial)

Proxy extends Socket
in package

HTTP Proxy-supporting Laminas\Http\Client adapter class, based on the default socket based adapter.

Should be used if proxy HTTP access is required. If no proxy is set, will fall back to Laminas\Http\Client\Adapter\Socket behavior. Just like the default Socket adapter, this adapter does not require any special extensions installed.

Table of Contents

Properties

$config  : array<string|int, mixed>
Parameters array
$connectedTo  : array<string|int, mixed>
What host/port are we connected to?
$context  : resource
Stream context
$method  : string
Request method - will be set by write() and might be used by read()
$negotiated  : bool
Whether HTTPS CONNECT was already negotiated with the proxy or not
$outStream  : resource
Stream for storing output
$setSslCryptoMethod  : bool
$socket  : resource|null
The socket for server connection
$sslCryptoTypes  : array<string|int, mixed>
Map SSL transport wrappers to stream crypto method constants

Methods

__construct()  : mixed
Adapter constructor, currently empty. Config is set using setOptions()
__destruct()  : mixed
Destructor: make sure the socket is disconnected
close()  : mixed
Close the connection to the server
connect()  : mixed
Connect to the remote server
getConfig()  : array<string|int, mixed>
Retrieve the array of all configuration options
getStreamContext()  : resource
Get the stream context for the TCP connection to the server.
read()  : string
Read response from server
setOptions()  : mixed
Set the configuration array for the adapter
setOutputStream()  : Socket
Set output stream for the response
setStreamContext()  : $this
Set the stream context for the TCP connection to the server
write()  : string
Send request to the proxy server
_checkSocketReadTimeout()  : mixed
Check if the socket has timed out - if so close connection and throw an exception
connectHandshake()  : mixed
Preform handshaking with HTTPS proxy using CONNECT method
enableCryptoTransport()  : mixed

Properties

$config

Parameters array

protected array<string|int, mixed> $config = ['persistent' => false, 'ssltransport' => 'tls', 'sslcert' => null, 'sslpassphrase' => null, 'sslverifypeer' => true, 'sslcafile' => null, 'sslcapath' => null, 'sslallowselfsigned' => false, 'sslusecontext' => false, 'sslverifypeername' => true, 'proxy_host' => '', 'proxy_port' => 8080, 'proxy_user' => '', 'proxy_pass' => '', 'proxy_auth' => \Laminas\Http\Client::AUTH_BASIC]

$connectedTo

What host/port are we connected to?

protected array<string|int, mixed> $connectedTo = [null, null]

$context

Stream context

protected resource $context

$method

Request method - will be set by write() and might be used by read()

protected string $method

$negotiated

Whether HTTPS CONNECT was already negotiated with the proxy or not

protected bool $negotiated = false

$outStream

Stream for storing output

protected resource $outStream

$setSslCryptoMethod

protected bool $setSslCryptoMethod = true

$socket

The socket for server connection

protected resource|null $socket

$sslCryptoTypes

Map SSL transport wrappers to stream crypto method constants

protected static array<string|int, mixed> $sslCryptoTypes = ['ssl' => \STREAM_CRYPTO_METHOD_SSLv23_CLIENT, 'sslv2' => \STREAM_CRYPTO_METHOD_SSLv2_CLIENT, 'sslv3' => \STREAM_CRYPTO_METHOD_SSLv3_CLIENT, 'tls' => \STREAM_CRYPTO_METHOD_TLS_CLIENT]

Methods

__construct()

Adapter constructor, currently empty. Config is set using setOptions()

public __construct() : mixed

__destruct()

Destructor: make sure the socket is disconnected

public __destruct() : mixed

close()

Close the connection to the server

public close() : mixed

connect()

Connect to the remote server

public connect(string $host[, int $port = 80 ][, bool $secure = false ]) : mixed

Will try to connect to the proxy server. If no proxy was set, will fall back to the target server (behave like regular Socket adapter)

Parameters
$host : string
$port : int = 80
$secure : bool = false
Tags
throws
RuntimeException

getConfig()

Retrieve the array of all configuration options

public getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed>

getStreamContext()

Get the stream context for the TCP connection to the server.

public getStreamContext() : resource

If no stream context is set, will create a default one.

Return values
resource

setOptions()

Set the configuration array for the adapter

public setOptions([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

setOutputStream()

Set output stream for the response

public setOutputStream(resource $stream) : Socket
Parameters
$stream : resource
Return values
Socket

setStreamContext()

Set the stream context for the TCP connection to the server

public setStreamContext(mixed $context) : $this

Can accept either a pre-existing stream context resource, or an array of stream options, similar to the options array passed to the stream_context_create() PHP function. In such case a new stream context will be created using the passed options.

Parameters
$context : mixed

Stream context or array of context options

Tags
since

Laminas 1.9

throws
InvalidArgumentException
Return values
$this

write()

Send request to the proxy server

public write(string $method, Uri $uri[, string $httpVer = '1.1' ][, array<string|int, mixed> $headers = [] ][, string $body = '' ]) : string
Parameters
$method : string
$uri : Uri
$httpVer : string = '1.1'
$headers : array<string|int, mixed> = []
$body : string = ''
Tags
throws
RuntimeException
Return values
string

Request as string

_checkSocketReadTimeout()

Check if the socket has timed out - if so close connection and throw an exception

protected _checkSocketReadTimeout() : mixed
Tags
throws
TimeoutException

with READ_TIMEOUT code

connectHandshake()

Preform handshaking with HTTPS proxy using CONNECT method

protected connectHandshake(string $host[, int $port = 443 ][, string $httpVer = '1.1' ][, array<string|int, mixed> &$headers = [] ]) : mixed
Parameters
$host : string
$port : int = 443
$httpVer : string = '1.1'
$headers : array<string|int, mixed> = []
Tags
throws
RuntimeException

enableCryptoTransport()

protected enableCryptoTransport(string $sslTransport, resource $socket, string $host) : mixed
Parameters
$sslTransport : string

Transport name from $config['ssltransport']

$socket : resource
$host : string

Host name used only for useful exception message


        
On this page

Search results