## API Documentation

# Http/Client/Adapter/Proxy.php

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

category
  Zend
copyright
  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
license
  New BSD License
package
  Zend_Http
subpackage
  Client_Adapter
version
  $Id: Proxy.php 23775 2011-03-01 17:25:24Z ralph $

## \Zend_Http_Client_Adapter_Proxy
jump to top

HTTP Proxy-supporting Zend_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 Zend_Http_Client_Adapter_Socket behavior. Just like the default Socket adapter, this adapter does not require any special extensions installed.

Extends from
  \Zend_Http_Client_Adapter_Socket
category
  Zend
copyright
  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
license
  New BSD License
package
  Zend_Http
subpackage
  Client_Adapter

### Properties

`array $config= 'array'`

Parameters array

Default value `array` Details

Type
  array

`boolean $negotiated= 'false'`

Whether HTTPS CONNECT was already negotiated with the proxy or not

Default value `false` Details

Type
  boolean

### Methods

`__construct( ) : void`

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

Inherited from: \Zend_Http_Client_Adapter_Socket::__construct()
`__destruct( ) : void`

Destructor: make sure the socket is disconnected

If we are in persistent TCP mode, will not close the connection

`_checkSocketReadTimeout( ) : void`

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

Inherited from: \Zend_Http_Client_Adapter_Socket::_checkSocketReadTimeout()
Throws

Exception | Description
--- | ---
\Zend_Http_Client_Adapter_Exception | with READ_TIMEOUT code

`close( ) : void`

Close the connection to the server

`connect( string $host, int $port = 80, boolean $secure = false ) : void`

Connect to the remote server

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

Name | Type | Description
--- | --- | ---
$host | string |
$port | int |
$secure | boolean |

`connectHandshake( string $host, integer $port = 443, string $http_ver = 1.1, array $headers = array ) : void`

Preform handshaking with HTTPS proxy using CONNECT method

Parameters

Name | Type | Description
--- | --- | ---
$host | string |
$port | integer |
$http_ver | string |
$headers | array |

`getConfig( ) : array`

Retrieve the array of all configuration options

Inherited from: \Zend_Http_Client_Adapter_Socket::getConfig()
Returns

Type | Description
--- | ---
array |

`getStreamContext( ) : resource`

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

Inherited from: \Zend_Http_Client_Adapter_Socket::getStreamContext()

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

Returns

Type | Description
--- | ---
resource |

`read( ) : string`

Read response from server

Inherited from: \Zend_Http_Client_Adapter_Socket::read()
Returns

Type | Description
--- | ---
string |

`setConfig( \Zend_Config $config = array ) : void`

Set the configuration array for the adapter

Inherited from: \Zend_Http_Client_Adapter_Socket::setConfig()
Parameters

Name | Type | Description
--- | --- | ---
$config | \Zend_Config | | array $config

`setOutputStream( resource $stream ) : \Zend_Http_Client_Adapter_Socket`

Set output stream for the response

Inherited from: \Zend_Http_Client_Adapter_Socket::setOutputStream()

This function sets output stream where the result will be stored.

Parameters

Name | Type | Description
--- | --- | ---
$stream | resource |

Returns

Type | Description
--- | ---
\Zend_Http_Client_Adapter_Socket |

`setStreamContext( mixed $context ) : \Zend_Http_Client_Adapter_Socket`

Set the stream context for the TCP connection to the server

Inherited from: \Zend_Http_Client_Adapter_Socket::setStreamContext()

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

Name | Type | Description
--- | --- | ---
$context | mixed | Stream context or array of context options

Returns

Type | Description
--- | ---
\Zend_Http_Client_Adapter_Socket |

Details

since
  Zend Framework 1.9

`write( string $method, \Zend_Uri_Http $uri, string $http_ver = 1.1, array $headers = array, string $body ) : string`

Send request to the proxy server

Parameters

Name | Type | Description
--- | --- | ---
$method | string |
$uri | \Zend_Uri_Http |
$http_ver | string |
$headers | array |
$body | string |

Returns

Type | Description
--- | ---
string | Request as string

Documentation was generated by DocBlox 0.13.3.