summaryrefslogtreecommitdiff
path: root/ext/soap/php_http.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2005-03-23 08:08:54 +0000
committerDmitry Stogov <dmitry@php.net>2005-03-23 08:08:54 +0000
commite31bc5a643a8dedac484e2a273ed921dd77f8911 (patch)
treedc6479f66043cfb09afaf7601b65d50b56cc851a /ext/soap/php_http.c
parent15ed825d6e4e072c4b2cb895147b049b0487aaac (diff)
downloadphp-git-e31bc5a643a8dedac484e2a273ed921dd77f8911.tar.gz
Allow define connection timeout throught "connection_timeout" option in SoapClient constructor.
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r--ext/soap/php_http.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index 97d5f4057d..7ce8dc9b60 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -82,7 +82,7 @@ static void proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_
static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, int *use_proxy TSRMLS_DC)
{
php_stream *stream;
- zval **proxy_host, **proxy_port;
+ zval **proxy_host, **proxy_port, **tmp;
char *host;
#ifdef ZEND_ENGINE_2
php_stream_context *context = NULL;
@@ -91,6 +91,8 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in
#endif
int port;
int old_error_reporting;
+ struct timeval tv;
+ struct timeval *timeout = NULL;
if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
Z_TYPE_PP(proxy_host) == IS_STRING &&
@@ -103,6 +105,12 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in
host = phpurl->host;
port = phpurl->port;
}
+ if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_connection_timeout", sizeof("_connection_timeout"), (void **) &tmp) == SUCCESS &&
+ Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) > 0) {
+ tv.tv_sec = Z_LVAL_PP(tmp);
+ tv.tv_usec = 0;
+ timeout = &tv;
+ }
old_error_reporting = EG(error_reporting);
EG(error_reporting) &= ~(E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE);
@@ -126,12 +134,12 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in
ENFORCE_SAFE_MODE | REPORT_ERRORS,
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT,
NULL /*persistent_id*/,
- NULL /*timeout*/,
+ timeout,
context,
NULL, NULL);
efree(name);
#else
- stream = php_stream_sock_open_host(host, port, SOCK_STREAM, NULL, NULL);
+ stream = php_stream_sock_open_host(host, port, SOCK_STREAM, timeout, NULL);
#endif
/* SSL & proxy */