diff options
author | Wez Furlong <wez@php.net> | 2005-07-19 19:48:02 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2005-07-19 19:48:02 +0000 |
commit | 3b5af6d43fa7ad23e6efb240e9475ce0040dd198 (patch) | |
tree | 8e5062654fb6ad70b135447c99a19c5a77a5abd5 /ext/soap | |
parent | 897090c01ed81790118767577431e331dcb9a98e (diff) | |
download | php-git-3b5af6d43fa7ad23e6efb240e9475ce0040dd198.tar.gz |
Remove stale #ifdefs (this is PHP 5 only code).
Add a stream_context option to the SoapClient constructor; this allows
generic stream context options to be set without having to add code to the
SoapClient every time a context option is added.
Diffstat (limited to 'ext/soap')
-rw-r--r-- | ext/soap/php_http.c | 41 | ||||
-rw-r--r-- | ext/soap/soap.c | 8 |
2 files changed, 18 insertions, 31 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 000ce4408f..9130cd60d2 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -110,11 +110,9 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in php_stream *stream; zval **proxy_host, **proxy_port, **tmp; char *host; -#ifdef ZEND_ENGINE_2 php_stream_context *context = NULL; char *name; long namelen; -#endif int port; int old_error_reporting; struct timeval tv; @@ -141,14 +139,19 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in old_error_reporting = EG(error_reporting); EG(error_reporting) &= ~(E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE); -#ifdef ZEND_ENGINE_2 + if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr), + "_stream_context", sizeof("_stream_context"), (void**)&tmp)) { + context = php_stream_context_from_zval(*tmp, 0); + } else { + context = php_stream_context_alloc(); + } + namelen = spprintf(&name, 0, "%s://%s:%d", (use_ssl && !*use_proxy)? "ssl" : "tcp", host, port); if (use_ssl) { zval **tmp; if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_local_cert", sizeof("_local_cert"), (void **) &tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING) { - context = php_stream_context_alloc(); php_stream_context_set_option(context, "ssl", "local_cert", *tmp); if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_passphrase", sizeof("_passphrase"), (void **) &tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING) { @@ -164,9 +167,6 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in context, NULL, NULL); efree(name); -#else - stream = php_stream_sock_open_host(host, port, SOCK_STREAM, timeout, NULL); -#endif /* SSL & proxy */ if (stream && *use_proxy && use_ssl) { @@ -194,7 +194,6 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in } efree(http_headers); } -#ifdef ZEND_ENGINE_2 /* enable SSL transport layer */ if (stream) { if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 || @@ -203,18 +202,8 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, in stream = NULL; } } -#endif } -#if !defined(ZEND_ENGINE_2) && defined(HAVE_OPENSSL_EXT) - if (stream && use_ssl) { - /* enable SSL transport layer */ - if (FAILURE == php_stream_sock_ssl_activate(stream, 1)) { - php_stream_close(stream); - stream = NULL; - } - } -#endif EG(error_reporting) = old_error_reporting; return stream; } @@ -339,23 +328,12 @@ try_again: add_soap_fault(this_ptr, "HTTP", "Unknown protocol. Only http and https are allowed.", NULL, NULL TSRMLS_CC); return FALSE; } -#ifdef ZEND_ENGINE_2 if (use_ssl && php_stream_locate_url_wrapper("https://", NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) == NULL) { php_url_free(phpurl); if (request != buf) {efree(request);} add_soap_fault(this_ptr, "HTTP", "SSL support not available in this build", NULL, NULL TSRMLS_CC); return FALSE; } -#else -#ifndef HAVE_OPENSSL_EXT - if (use_ssl) { - php_url_free(phpurl); - if (request != buf) {efree(request);} - add_soap_fault(this_ptr, "HTTP", "SSL support not available in this build", NULL, NULL TSRMLS_CC); - return FALSE; - } -#endif -#endif if (phpurl->port == 0) { phpurl->port = use_ssl ? 443 : 80; @@ -687,6 +665,9 @@ try_again: } smart_str_free(&soap_headers); + } else { + add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL TSRMLS_CC); + return FALSE; } do { @@ -951,9 +932,7 @@ try_again: if (digest != NULL) { php_url *new_url = emalloc(sizeof(php_url)); -#ifdef ZEND_ENGINE_2 digest->refcount--; -#endif add_property_zval_ex(this_ptr, "_digest", sizeof("_digest"), digest TSRMLS_CC); *new_url = *phpurl; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 2efc6356c6..20e6b699e8 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -2072,6 +2072,14 @@ PHP_METHOD(SoapClient, SoapClient) } } + if (zend_hash_find(ht, "stream_context", sizeof("stream_context"), (void**)&tmp) == SUCCESS && + Z_TYPE_PP(tmp) == IS_RESOURCE) { + php_stream_context *context = php_stream_context_from_zval(*tmp, 1); + if (context) { + add_property_resource(this_ptr, "_stream_context", context->rsrc_id); + } + } + if (zend_hash_find(ht, "location", sizeof("location"), (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING) { add_property_stringl(this_ptr, "location", Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1); |