Browse Source

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.
PHP-5.1
Wez Furlong 21 years ago
parent
commit
3b5af6d43f
  1. 41
      ext/soap/php_http.c
  2. 8
      ext/soap/soap.c

41
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;

8
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);

Loading…
Cancel
Save