PHP 클래스 Zend_Http_Client

파일 보기 프로젝트 열기: dbpatch/dbpatch 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_fileInfoDb resource This variable is populated the first time _detectFileMimeType is called and is then reused on every call to this method
$_queryBracketsEscaped boolean Status if the http_build_query function escapes brackets
$_unmaskStatus boolean Status for unmasking GET array params
$adapter Zend_Http_Client_Adapter_Interface The adapter used to perform the actual connection to the server
$auth array | null Expected to be an associative array with this structure: $this->auth = array('user' => 'username', 'password' => 'password', 'type' => 'basic') Where 'type' should be one of the supported authentication types (see the AUTH_* constants), for example 'basic' or 'digest'. If null, no authentication will be used.
$body_field_order array An associative array, where each element is of the format: '' => VTYPE_SCALAR | VTYPE_FILE
$config array Configuration array, set using the constructor or using ::setConfig()
$cookiejar Zend_Http_CookieJar The client's cookie jar
$enctype string Request body content type (for POST requests)
$files array An associative array, where each element is of the format: 'name' => array('filename.txt', 'text/plain', 'This is the actual file contents')
$headers array Associative array of request headers
$last_request string The last HTTP request sent by the client, as string
$last_response Zend_Http_Response The last HTTP response received by the client
$method string HTTP request method
$paramsGet array Associative array of GET parameters
$paramsPost array Associative array of POST parameters
$raw_post_data string The raw post data to send. Could be set by setRawData($data, $enctype).
$redirectCounter integer Redirection counter
$uri Zend_Uri_Http Request URI

공개 메소드들

메소드 설명
__construct ( Zend_Uri_Http | string $uri = null, array $config = null ) Constructor method. Will create a new HTTP client. Accepts the target URL and optionally configuration array.
encodeAuthHeader ( string $user, string $password, string $type = self::AUTH_BASIC ) : string Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
encodeFormData ( string $boundary, string $name, mixed $value, string $filename = null, array $headers = [] ) : string Encode data to a multipart/form-data part suitable for a POST request.
getAdapter ( ) : Zend_Http_Client_Adapter_Interface Load the connection adapter
getCookieJar ( ) : Zend_Http_CookieJar | null Return the current cookie jar or null if none.
getHeader ( string $key ) : string | array | null Get the value of a specific header
getLastRequest ( ) : string Get the last HTTP request as string
getLastResponse ( ) : Zend_Http_Response Get the last HTTP response received by this client
getRedirectionsCount ( ) : integer Get the number of redirections done on the last request
getStream ( ) : boolean | string Get status of streaming for received data
getUnmaskStatus ( ) : boolean Returns the currently configured unmask status
getUri ( boolean $as_string = false ) : Zend_Uri_Http | string Get the URI for the next request
request ( string $method = null ) : Zend_Http_Response Send the HTTP request and return an HTTP response object
resetParameters ( boolean $clearAll = false ) : Zend_Http_Client Clear all GET and POST parameters
setAdapter ( Zend_Http_Client_Adapter_Interface | string $adapter ) : null Load the connection adapter
setAuth ( string | false $user, string $password = '', string $type = self::AUTH_BASIC ) : Zend_Http_Client Set HTTP authentication parameters
setConfig ( $config = [] ) : Zend_Http_Client Set configuration parameters for this HTTP client
setCookie ( Zend_Http_Cookie | string $cookie, string | null $value = null ) : Zend_Http_Client Add a cookie to the request. If the client has no Cookie Jar, the cookies will be added directly to the headers array as "Cookie" headers.
setCookieJar ( Zend_Http_CookieJar | boolean $cookiejar = true ) : Zend_Http_Client Set the HTTP client's cookie jar.
setEncType ( string $enctype = self::ENC_URLENCODED ) : Zend_Http_Client Set the encoding type for POST data
setFileUpload ( string $filename, string $formname, string $data = null, string $ctype = null ) : Zend_Http_Client Set a file to upload (using a POST request)
setHeaders ( string | array $name, mixed $value = null ) : Zend_Http_Client Set one or more request headers
setMethod ( string $method = self::GET ) : Zend_Http_Client Set the next request's method
setParameterGet ( string | array $name, string $value = null ) : Zend_Http_Client Set a GET parameter for the request. Wrapper around _setParameter
setParameterPost ( string | array $name, string $value = null ) : Zend_Http_Client Set a POST parameter for the request. Wrapper around _setParameter
setRawData ( string | resource $data, string $enctype = null ) : Zend_Http_Client Set the raw (already encoded) POST data.
setStream ( string | boolean $streamfile = true ) : Zend_Http_Client Set streaming for received data
setUnmaskStatus ( boolean $status = true ) : Zend_Http_Client Set the unmask feature for GET parameters as array
setUri ( Zend_Uri_Http | string $uri ) : Zend_Http_Client Set the URI for the next request

보호된 메소드들

메소드 설명
_detectFileMimeType ( string $file ) : string Attempt to detect the MIME type of a file using available extensions
_flattenParametersArray ( array $parray, string $prefix = null ) : array Convert an array of parameters into a flat array of (key, value) pairs
_getParametersRecursive ( array $parray, boolean $urlencode = false ) : array Helper method that gets a possibly multi-level parameters array (get or post) and flattens it.
_openTempStream ( ) : resource Create temporary stream
_prepareBody ( ) : string Prepare the request body (for POST and PUT requests)
_prepareHeaders ( ) : array Prepare the request headers
_setParameter ( string $type, string $name, string $value ) : null Set a GET or POST parameter - used by SetParameterGet and SetParameterPost

메소드 상세

__construct() 공개 메소드

Constructor method. Will create a new HTTP client. Accepts the target URL and optionally configuration array.
public __construct ( Zend_Uri_Http | string $uri = null, array $config = null )
$uri Zend_Uri_Http | string
$config array Configuration key-value pairs.

_detectFileMimeType() 보호된 메소드

This method will try to detect the MIME type of a file. If the fileinfo extension is available, it will be used. If not, the mime_magic extension which is deprected but is still available in many PHP setups will be tried. If neither extension is available, the default application/octet-stream MIME type will be returned
protected _detectFileMimeType ( string $file ) : string
$file string File path
리턴 string MIME type

_flattenParametersArray() 보호된 정적인 메소드

Will flatten a potentially multi-dimentional array of parameters (such as POST parameters) into a flat array of (key, value) paris. In case of multi-dimentional arrays, square brackets ([]) will be added to the key to indicate an array.
부터: 1.9
protected static _flattenParametersArray ( array $parray, string $prefix = null ) : array
$parray array
$prefix string
리턴 array

_getParametersRecursive() 보호된 메소드

The method returns an array of (key, value) pairs (because keys are not necessarily unique. If one of the parameters in as array, it will also add a [] suffix to the key. This method is deprecated since Zend Framework 1.9 in favour of self::_flattenParametersArray() and will be dropped in 2.0
사용 중단: since 1.9
protected _getParametersRecursive ( array $parray, boolean $urlencode = false ) : array
$parray array The parameters array
$urlencode boolean Whether to urlencode the name and value
리턴 array

_openTempStream() 보호된 메소드

Create temporary stream
protected _openTempStream ( ) : resource
리턴 resource

_prepareBody() 보호된 메소드

Prepare the request body (for POST and PUT requests)
protected _prepareBody ( ) : string
리턴 string

_prepareHeaders() 보호된 메소드

Prepare the request headers
protected _prepareHeaders ( ) : array
리턴 array

_setParameter() 보호된 메소드

Set a GET or POST parameter - used by SetParameterGet and SetParameterPost
protected _setParameter ( string $type, string $name, string $value ) : null
$type string GET or POST
$name string
$value string
리턴 null

encodeAuthHeader() 공개 정적인 메소드

Create a HTTP authentication "Authorization:" header according to the specified user, password and authentication method.
또한 보기: http://www.faqs.org/rfcs/rfc2617.html
public static encodeAuthHeader ( string $user, string $password, string $type = self::AUTH_BASIC ) : string
$user string
$password string
$type string
리턴 string

encodeFormData() 공개 정적인 메소드

Encode data to a multipart/form-data part suitable for a POST request.
public static encodeFormData ( string $boundary, string $name, mixed $value, string $filename = null, array $headers = [] ) : string
$boundary string
$name string
$value mixed
$filename string
$headers array Associative array of optional headers @example ("Content-Transfer-Encoding" => "binary")
리턴 string

getAdapter() 공개 메소드

Load the connection adapter
public getAdapter ( ) : Zend_Http_Client_Adapter_Interface
리턴 Zend_Http_Client_Adapter_Interface $adapter

getCookieJar() 공개 메소드

Return the current cookie jar or null if none.
public getCookieJar ( ) : Zend_Http_CookieJar | null
리턴 Zend_Http_CookieJar | null

getHeader() 공개 메소드

Note that if the header has more than one value, an array will be returned.
public getHeader ( string $key ) : string | array | null
$key string
리턴 string | array | null The header value or null if it is not set

getLastRequest() 공개 메소드

Get the last HTTP request as string
public getLastRequest ( ) : string
리턴 string

getLastResponse() 공개 메소드

If $config['storeresponse'] is set to false, or no response was stored yet, will return null
public getLastResponse ( ) : Zend_Http_Response
리턴 Zend_Http_Response or null if none

getRedirectionsCount() 공개 메소드

Get the number of redirections done on the last request
public getRedirectionsCount ( ) : integer
리턴 integer

getStream() 공개 메소드

Get status of streaming for received data
public getStream ( ) : boolean | string
리턴 boolean | string

getUnmaskStatus() 공개 메소드

Returns the currently configured unmask status
public getUnmaskStatus ( ) : boolean
리턴 boolean

getUri() 공개 메소드

Get the URI for the next request
public getUri ( boolean $as_string = false ) : Zend_Uri_Http | string
$as_string boolean If true, will return the URI as a string
리턴 Zend_Uri_Http | string

request() 공개 메소드

Send the HTTP request and return an HTTP response object
public request ( string $method = null ) : Zend_Http_Response
$method string
리턴 Zend_Http_Response

resetParameters() 공개 메소드

Should be used to reset the request parameters if the client is used for several concurrent requests. clearAll parameter controls if we clean just parameters or also headers and last_*
public resetParameters ( boolean $clearAll = false ) : Zend_Http_Client
$clearAll boolean Should all data be cleared?
리턴 Zend_Http_Client

setAdapter() 공개 메소드

While this method is not called more than one for a client, it is seperated from ->request() to preserve logic and readability
public setAdapter ( Zend_Http_Client_Adapter_Interface | string $adapter ) : null
$adapter Zend_Http_Client_Adapter_Interface | string
리턴 null

setAuth() 공개 메소드

$type should be one of the supported types - see the self::AUTH_* constants. To enable authentication: $this->setAuth('shahar', 'secret', Zend_Http_Client::AUTH_BASIC); To disable authentication: $this->setAuth(false);
또한 보기: http://www.faqs.org/rfcs/rfc2617.html
public setAuth ( string | false $user, string $password = '', string $type = self::AUTH_BASIC ) : Zend_Http_Client
$user string | false User name or false disable authentication
$password string Password
$type string Authentication type
리턴 Zend_Http_Client

setConfig() 공개 메소드

Set configuration parameters for this HTTP client
public setConfig ( $config = [] ) : Zend_Http_Client
리턴 Zend_Http_Client

setCookie() 공개 메소드

Add a cookie to the request. If the client has no Cookie Jar, the cookies will be added directly to the headers array as "Cookie" headers.
public setCookie ( Zend_Http_Cookie | string $cookie, string | null $value = null ) : Zend_Http_Client
$cookie Zend_Http_Cookie | string
$value string | null If "cookie" is a string, this is the cookie value.
리턴 Zend_Http_Client

setCookieJar() 공개 메소드

A cookie jar is an object that holds and maintains cookies across HTTP requests and responses.
public setCookieJar ( Zend_Http_CookieJar | boolean $cookiejar = true ) : Zend_Http_Client
$cookiejar Zend_Http_CookieJar | boolean Existing cookiejar object, true to create a new one, false to disable
리턴 Zend_Http_Client

setEncType() 공개 메소드

Set the encoding type for POST data
public setEncType ( string $enctype = self::ENC_URLENCODED ) : Zend_Http_Client
$enctype string
리턴 Zend_Http_Client

setFileUpload() 공개 메소드

Can be used in two ways: 1. $data is null (default): $filename is treated as the name if a local file which will be read and sent. Will try to guess the content type using mime_content_type(). 2. $data is set - $filename is sent as the file name, but $data is sent as the file contents and no file is read from the file system. In this case, you need to manually set the Content-Type ($ctype) or it will default to application/octet-stream.
public setFileUpload ( string $filename, string $formname, string $data = null, string $ctype = null ) : Zend_Http_Client
$filename string Name of file to upload, or name to save as
$formname string Name of form element to send as
$data string Data to send (if null, $filename is read and sent)
$ctype string Content type to use (if $data is set and $ctype is null, will be application/octet-stream)
리턴 Zend_Http_Client

setHeaders() 공개 메소드

This function can be used in several ways to set the client's request headers: 1. By providing two parameters: $name as the header to set (e.g. 'Host') and $value as it's value (e.g. 'www.example.com'). 2. By providing a single header string as the only parameter e.g. 'Host: www.example.com' 3. By providing an array of headers as the first parameter e.g. array('host' => 'www.example.com', 'x-foo: bar'). In This case the function will call itself recursively for each array item.
public setHeaders ( string | array $name, mixed $value = null ) : Zend_Http_Client
$name string | array Header name, full header string ('Header: value') or an array of headers
$value mixed Header value or null
리턴 Zend_Http_Client

setMethod() 공개 메소드

Validated the passed method and sets it. If we have files set for POST requests, and the new method is not POST, the files are silently dropped.
public setMethod ( string $method = self::GET ) : Zend_Http_Client
$method string
리턴 Zend_Http_Client

setParameterGet() 공개 메소드

Set a GET parameter for the request. Wrapper around _setParameter
public setParameterGet ( string | array $name, string $value = null ) : Zend_Http_Client
$name string | array
$value string
리턴 Zend_Http_Client

setParameterPost() 공개 메소드

Set a POST parameter for the request. Wrapper around _setParameter
public setParameterPost ( string | array $name, string $value = null ) : Zend_Http_Client
$name string | array
$value string
리턴 Zend_Http_Client

setRawData() 공개 메소드

This function is here for two reasons: 1. For advanced user who would like to set their own data, already encoded 2. For backwards compatibilty: If someone uses the old post($data) method. this method will be used to set the encoded data. $data can also be stream (such as file) from which the data will be read.
public setRawData ( string | resource $data, string $enctype = null ) : Zend_Http_Client
$data string | resource
$enctype string
리턴 Zend_Http_Client

setStream() 공개 메소드

Set streaming for received data
public setStream ( string | boolean $streamfile = true ) : Zend_Http_Client
$streamfile string | boolean Stream file, true for temp file, false/null for no streaming
리턴 Zend_Http_Client

setUnmaskStatus() 공개 메소드

Example: foo%5B0%5D=a&foo%5B1%5D=b becomes foo=a&foo=b This is usefull for some services
public setUnmaskStatus ( boolean $status = true ) : Zend_Http_Client
$status boolean
리턴 Zend_Http_Client

setUri() 공개 메소드

Set the URI for the next request
public setUri ( Zend_Uri_Http | string $uri ) : Zend_Http_Client
$uri Zend_Uri_Http | string
리턴 Zend_Http_Client

프로퍼티 상세

$_fileInfoDb 보호되어 있는 정적으로 프로퍼티

This variable is populated the first time _detectFileMimeType is called and is then reused on every call to this method
protected static resource $_fileInfoDb
리턴 resource

$_queryBracketsEscaped 보호되어 있는 프로퍼티

Status if the http_build_query function escapes brackets
protected bool $_queryBracketsEscaped
리턴 boolean

$_unmaskStatus 보호되어 있는 프로퍼티

Status for unmasking GET array params
protected bool $_unmaskStatus
리턴 boolean

$adapter 보호되어 있는 프로퍼티

The adapter used to perform the actual connection to the server
protected Zend_Http_Client_Adapter_Interface $adapter
리턴 Zend_Http_Client_Adapter_Interface

$auth 보호되어 있는 프로퍼티

Expected to be an associative array with this structure: $this->auth = array('user' => 'username', 'password' => 'password', 'type' => 'basic') Where 'type' should be one of the supported authentication types (see the AUTH_* constants), for example 'basic' or 'digest'. If null, no authentication will be used.
protected array|null $auth
리턴 array | null

$body_field_order 보호되어 있는 프로퍼티

An associative array, where each element is of the format: '' => VTYPE_SCALAR | VTYPE_FILE
protected array $body_field_order
리턴 array

$config 보호되어 있는 프로퍼티

Configuration array, set using the constructor or using ::setConfig()
protected array $config
리턴 array

$cookiejar 보호되어 있는 프로퍼티

The client's cookie jar
protected Zend_Http_CookieJar $cookiejar
리턴 Zend_Http_CookieJar

$enctype 보호되어 있는 프로퍼티

Request body content type (for POST requests)
protected string $enctype
리턴 string

$files 보호되어 있는 프로퍼티

An associative array, where each element is of the format: 'name' => array('filename.txt', 'text/plain', 'This is the actual file contents')
protected array $files
리턴 array

$headers 보호되어 있는 프로퍼티

Associative array of request headers
protected array $headers
리턴 array

$last_request 보호되어 있는 프로퍼티

The last HTTP request sent by the client, as string
protected string $last_request
리턴 string

$last_response 보호되어 있는 프로퍼티

The last HTTP response received by the client
protected Zend_Http_Response $last_response
리턴 Zend_Http_Response

$method 보호되어 있는 프로퍼티

HTTP request method
protected string $method
리턴 string

$paramsGet 보호되어 있는 프로퍼티

Associative array of GET parameters
protected array $paramsGet
리턴 array

$paramsPost 보호되어 있는 프로퍼티

Associative array of POST parameters
protected array $paramsPost
리턴 array

$raw_post_data 보호되어 있는 프로퍼티

The raw post data to send. Could be set by setRawData($data, $enctype).
protected string $raw_post_data
리턴 string

$redirectCounter 보호되어 있는 프로퍼티

Redirection counter
protected int $redirectCounter
리턴 integer

$uri 보호되어 있는 프로퍼티

Request URI
protected Zend_Uri_Http $uri
리턴 Zend_Uri_Http