wez Tue Jul 19 15:48:04 2005 EDT
Modified files:
/php-src/ext/soap php_http.c soap.c
Log:
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.
http://cvs.php.net/diff.php/php-src/ext/soap/php_http.c?r1=1.73&r2=1.74&ty=u
Index: php-src/ext/soap/php_http.c
diff -u php-src/ext/soap/php_http.c:1.73 php-src/ext/soap/php_http.c:1.74
--- php-src/ext/soap/php_http.c:1.73 Fri Jul 8 05:36:28 2005
+++ php-src/ext/soap/php_http.c Tue Jul 19 15:48:02 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_http.c,v 1.73 2005/07/08 09:36:28 dmitry Exp $ */
+/* $Id: php_http.c,v 1.74 2005/07/19 19:48:02 wez Exp $ */
#include "php_soap.h"
#include "ext/standard/base64.h"
@@ -110,11 +110,9 @@
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
}
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 @@
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;
http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.153&r2=1.154&ty=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.153 php-src/ext/soap/soap.c:1.154
--- php-src/ext/soap/soap.c:1.153 Wed Jul 6 02:58:44 2005
+++ php-src/ext/soap/soap.c Tue Jul 19 15:48:02 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: soap.c,v 1.153 2005/07/06 06:58:44 dmitry Exp $ */
+/* $Id: soap.c,v 1.154 2005/07/19 19:48:02 wez Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2072,6 +2072,14 @@
}
}
+ 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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php