Skip to content

Commit e6c6abf

Browse files
committed
Declare remaining SoapClient properties
1 parent b3b1658 commit e6c6abf

File tree

7 files changed

+452
-245
lines changed

7 files changed

+452
-245
lines changed

ext/soap/php_http.c

Lines changed: 98 additions & 88 deletions
Large diffs are not rendered by default.

ext/soap/php_sdl.c

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,7 +3163,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
31633163
char* old_error_code = SOAP_GLOBAL(error_code);
31643164
size_t uri_len = 0;
31653165
php_stream_context *context=NULL;
3166-
zval *tmp, *proxy_host, *proxy_port, orig_context, new_context;
3166+
zval *tmp, orig_context, new_context;
31673167
smart_str headers = {0};
31683168
char* key = NULL;
31693169
time_t t = time(0);
@@ -3237,49 +3237,55 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
32373237
}
32383238
}
32393239

3240-
if (NULL != (tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr),
3241-
"_stream_context", sizeof("_stream_context")-1))) {
3242-
context = php_stream_context_from_zval(tmp, 0);
3243-
} else {
3244-
context = php_stream_context_alloc();
3245-
}
3240+
if (instanceof_function(Z_OBJCE_P(this_ptr), soap_class_entry)) {
3241+
tmp = Z_CLIENT_STREAM_CONTEXT_P(this_ptr);
3242+
if (Z_TYPE_P(tmp) == IS_RESOURCE) {
3243+
context = php_stream_context_from_zval(tmp, 0);
3244+
}
32463245

3247-
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_user_agent", sizeof("_user_agent")-1)) != NULL &&
3248-
Z_TYPE_P(tmp) == IS_STRING && Z_STRLEN_P(tmp) > 0) {
3249-
smart_str_appends(&headers, "User-Agent: ");
3250-
smart_str_appends(&headers, Z_STRVAL_P(tmp));
3251-
smart_str_appends(&headers, "\r\n");
3252-
}
3246+
tmp = Z_CLIENT_USER_AGENT_P(this_ptr);
3247+
ZVAL_DEREF(tmp);
3248+
if (Z_TYPE_P(tmp) == IS_STRING && Z_STRLEN_P(tmp) > 0) {
3249+
smart_str_appends(&headers, "User-Agent: ");
3250+
smart_str_appends(&headers, Z_STRVAL_P(tmp));
3251+
smart_str_appends(&headers, "\r\n");
3252+
}
32533253

3254-
if ((proxy_host = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host")-1)) != NULL &&
3255-
Z_TYPE_P(proxy_host) == IS_STRING &&
3256-
(proxy_port = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port")-1)) != NULL &&
3257-
Z_TYPE_P(proxy_port) == IS_LONG) {
3258-
zval str_proxy;
3259-
smart_str proxy = {0};
3260-
smart_str_appends(&proxy,"tcp://");
3261-
smart_str_appends(&proxy,Z_STRVAL_P(proxy_host));
3262-
smart_str_appends(&proxy,":");
3263-
smart_str_append_long(&proxy,Z_LVAL_P(proxy_port));
3264-
smart_str_0(&proxy);
3265-
ZVAL_NEW_STR(&str_proxy, proxy.s);
3254+
zval *proxy_host = Z_CLIENT_PROXY_HOST_P(this_ptr);
3255+
zval *proxy_port = Z_CLIENT_PROXY_PORT_P(this_ptr);
3256+
ZVAL_DEREF(proxy_host);
3257+
ZVAL_DEREF(proxy_port);
3258+
if (Z_TYPE_P(proxy_host) == IS_STRING && Z_TYPE_P(proxy_port) == IS_LONG) {
3259+
zval str_proxy;
3260+
smart_str proxy = {0};
3261+
smart_str_appends(&proxy,"tcp://");
3262+
smart_str_appends(&proxy,Z_STRVAL_P(proxy_host));
3263+
smart_str_appends(&proxy,":");
3264+
smart_str_append_long(&proxy,Z_LVAL_P(proxy_port));
3265+
smart_str_0(&proxy);
3266+
ZVAL_NEW_STR(&str_proxy, proxy.s);
32663267

3267-
if (!context) {
3268-
context = php_stream_context_alloc();
3269-
}
3270-
php_stream_context_set_option(context, "http", "proxy", &str_proxy);
3271-
zval_ptr_dtor(&str_proxy);
3268+
if (!context) {
3269+
context = php_stream_context_alloc();
3270+
}
3271+
php_stream_context_set_option(context, "http", "proxy", &str_proxy);
3272+
zval_ptr_dtor(&str_proxy);
32723273

3273-
if (uri_len < sizeof("https://")-1 ||
3274-
strncasecmp(uri, "https://", sizeof("https://")-1) != 0) {
3275-
ZVAL_TRUE(&str_proxy);
3276-
php_stream_context_set_option(context, "http", "request_fulluri", &str_proxy);
3274+
if (uri_len < sizeof("https://")-1 ||
3275+
strncasecmp(uri, "https://", sizeof("https://")-1) != 0) {
3276+
ZVAL_TRUE(&str_proxy);
3277+
php_stream_context_set_option(context, "http", "request_fulluri", &str_proxy);
3278+
}
3279+
3280+
has_proxy_authorization = proxy_authentication(this_ptr, &headers);
32773281
}
32783282

3279-
has_proxy_authorization = proxy_authentication(this_ptr, &headers);
3283+
has_authorization = basic_authentication(this_ptr, &headers);
32803284
}
32813285

3282-
has_authorization = basic_authentication(this_ptr, &headers);
3286+
if (!context) {
3287+
context = php_stream_context_alloc();
3288+
}
32833289

32843290
/* Use HTTP/1.1 with "Connection: close" by default */
32853291
if ((tmp = php_stream_context_get_option(context, "http", "protocol_version")) == NULL) {

ext/soap/php_soap.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ ZEND_EXTERN_MODULE_GLOBALS(soap)
192192
ZEND_TSRMLS_CACHE_EXTERN()
193193
#endif
194194

195+
extern zend_class_entry* soap_class_entry;
195196
extern zend_class_entry* soap_var_class_entry;
196197

197198
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
@@ -218,5 +219,31 @@ void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault
218219
#define Z_CLIENT_TYPEMAP_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 7)
219220
#define Z_CLIENT_HTTPSOCKET_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 8)
220221
#define Z_CLIENT_HTTPURL_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 9)
222+
#define Z_CLIENT_LOGIN_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 10)
223+
#define Z_CLIENT_PASSWORD_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 11)
224+
#define Z_CLIENT_USE_DIGEST_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 12)
225+
#define Z_CLIENT_DIGEST_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 13)
226+
#define Z_CLIENT_PROXY_HOST_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 14)
227+
#define Z_CLIENT_PROXY_PORT_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 15)
228+
#define Z_CLIENT_PROXY_LOGIN_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 16)
229+
#define Z_CLIENT_PROXY_PASSWORD_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 17)
230+
#define Z_CLIENT_EXCEPTIONS_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 18)
231+
#define Z_CLIENT_ENCODING_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 19)
232+
#define Z_CLIENT_CLASSMAP_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 20)
233+
#define Z_CLIENT_FEATURES_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 21)
234+
#define Z_CLIENT_CONNECTION_TIMEOUT_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 22)
235+
#define Z_CLIENT_STREAM_CONTEXT_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 23)
236+
#define Z_CLIENT_USER_AGENT_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 24)
237+
#define Z_CLIENT_KEEP_ALIVE_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 25)
238+
#define Z_CLIENT_SSL_METHOD_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 26)
239+
#define Z_CLIENT_SOAP_VERSION_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 27)
240+
#define Z_CLIENT_USE_PROXY_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 28)
241+
#define Z_CLIENT_COOKIES_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 29)
242+
#define Z_CLIENT_DEFAULT_HEADERS_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 30)
243+
#define Z_CLIENT_SOAP_FAULT_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 31)
244+
#define Z_CLIENT_LAST_REQUEST_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 32)
245+
#define Z_CLIENT_LAST_RESPONSE_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 33)
246+
#define Z_CLIENT_LAST_REQUEST_HEADERS_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 34)
247+
#define Z_CLIENT_LAST_RESPONSE_HEADERS_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 35)
221248

222249
#endif

0 commit comments

Comments
 (0)