summaryrefslogtreecommitdiff
path: root/ext/soap/php_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r--ext/soap/php_http.c116
1 files changed, 58 insertions, 58 deletions
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index bb2a6c7a53..0935ce36ad 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -40,10 +40,10 @@ int proxy_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
zend_string *buf;
smart_str auth = {0};
- smart_str_appendl(&auth, Z_STRVAL_P(login), Z_STRLEN_P(login));
+ smart_str_appendl(&auth, Z_STRVAL_P(login), Z_STRSIZE_P(login));
smart_str_appendc(&auth, ':');
if ((password = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_proxy_password", sizeof("_proxy_password")-1)) != NULL) {
- smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRLEN_P(password));
+ smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRSIZE_P(password));
}
smart_str_0(&auth);
buf = php_base64_encode((unsigned char*)auth.s->val, auth.s->len);
@@ -67,10 +67,10 @@ int basic_authentication(zval* this_ptr, smart_str* soap_headers TSRMLS_DC)
zend_string* buf;
smart_str auth = {0};
- smart_str_appendl(&auth, Z_STRVAL_P(login), Z_STRLEN_P(login));
+ smart_str_appendl(&auth, Z_STRVAL_P(login), Z_STRSIZE_P(login));
smart_str_appendc(&auth, ':');
if ((password = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password")-1)) != NULL) {
- smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRLEN_P(password));
+ smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRSIZE_P(password));
}
smart_str_0(&auth);
buf = php_base64_encode((unsigned char*)auth.s->val, auth.s->len);
@@ -95,7 +95,7 @@ void http_context_headers(php_stream_context* context,
if (context &&
(tmp = php_stream_context_get_option(context, "http", "header")) != NULL &&
- Z_TYPE_P(tmp) == IS_STRING && Z_STRLEN_P(tmp)) {
+ Z_TYPE_P(tmp) == IS_STRING && Z_STRSIZE_P(tmp)) {
char *s = Z_STRVAL_P(tmp);
char *p;
int name_len;
@@ -161,7 +161,7 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
char *host;
char *name;
char *protocol;
- long namelen;
+ php_int_t namelen;
int port;
int old_error_reporting;
struct timeval tv;
@@ -170,17 +170,17 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
if ((proxy_host = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host")-1)) != NULL &&
Z_TYPE_P(proxy_host) == IS_STRING &&
(proxy_port = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_proxy_port", sizeof("_proxy_port")-1)) != NULL &&
- Z_TYPE_P(proxy_port) == IS_LONG) {
+ Z_TYPE_P(proxy_port) == IS_INT) {
host = Z_STRVAL_P(proxy_host);
- port = Z_LVAL_P(proxy_port);
+ port = Z_IVAL_P(proxy_port);
*use_proxy = 1;
} else {
host = phpurl->host;
port = phpurl->port;
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_connection_timeout", sizeof("_connection_timeout")-1)) != NULL &&
- Z_TYPE_P(tmp) == IS_LONG && Z_LVAL_P(tmp) > 0) {
- tv.tv_sec = Z_LVAL_P(tmp);
+ Z_TYPE_P(tmp) == IS_INT && Z_IVAL_P(tmp) > 0) {
+ tv.tv_sec = Z_IVAL_P(tmp);
tv.tv_usec = 0;
timeout = &tv;
}
@@ -191,9 +191,9 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
/* Changed ternary operator to an if/else so that additional comparisons can be done on the ssl_method property */
if (use_ssl && !*use_proxy) {
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_ssl_method", sizeof("_ssl_method")-1)) != NULL &&
- Z_TYPE_P(tmp) == IS_LONG) {
+ Z_TYPE_P(tmp) == IS_INT) {
/* uses constants declared in soap.c to determine ssl uri protocol */
- switch (Z_LVAL_P(tmp)) {
+ switch (Z_IVAL_P(tmp)) {
case SOAP_SSL_METHOD_TLS:
protocol = "tls";
break;
@@ -274,8 +274,8 @@ static php_stream* http_connect(zval* this_ptr, php_url *phpurl, int use_ssl, ph
proper encrypyion method based on constants defined in soap.c */
int crypto_method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_ssl_method", sizeof("_ssl_method")-1)) != NULL &&
- Z_TYPE_P(tmp) == IS_LONG) {
- switch (Z_LVAL_P(tmp)) {
+ Z_TYPE_P(tmp) == IS_INT) {
+ switch (Z_IVAL_P(tmp)) {
case SOAP_SSL_METHOD_TLS:
crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT;
break;
@@ -347,7 +347,7 @@ int make_http_soap_request(zval *this_ptr,
int http_1_1;
int http_status;
int content_type_xml = 0;
- long redirect_max = 20;
+ php_int_t redirect_max = 20;
char *content_encoding;
char *http_msg = NULL;
zend_bool old_allow_url_fopen;
@@ -363,13 +363,13 @@ int make_http_soap_request(zval *this_ptr,
request = buf;
request_size = buf_size;
/* Compress request */
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "compression", sizeof("compression")-1)) != NULL && Z_TYPE_P(tmp) == IS_LONG) {
- int level = Z_LVAL_P(tmp) & 0x0f;
- int kind = Z_LVAL_P(tmp) & SOAP_COMPRESSION_DEFLATE;
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "compression", sizeof("compression")-1)) != NULL && Z_TYPE_P(tmp) == IS_INT) {
+ int level = Z_IVAL_P(tmp) & 0x0f;
+ int kind = Z_IVAL_P(tmp) & SOAP_COMPRESSION_DEFLATE;
if (level > 9) {level = 9;}
- if ((Z_LVAL_P(tmp) & SOAP_COMPRESSION_ACCEPT) != 0) {
+ if ((Z_IVAL_P(tmp) & SOAP_COMPRESSION_ACCEPT) != 0) {
smart_str_append_const(&soap_headers_z,"Accept-Encoding: gzip, deflate\r\n");
}
if (level > 0) {
@@ -379,7 +379,7 @@ int make_http_soap_request(zval *this_ptr,
int n;
ZVAL_STRINGL(&params[0], buf, buf_size);
- ZVAL_LONG(&params[1], level);
+ ZVAL_INT(&params[1], level);
if (kind == SOAP_COMPRESSION_DEFLATE) {
n = 2;
ZVAL_STRING(&func, "gzcompress");
@@ -388,7 +388,7 @@ int make_http_soap_request(zval *this_ptr,
n = 3;
ZVAL_STRING(&func, "gzencode");
smart_str_append_const(&soap_headers_z,"Content-Encoding: gzip\r\n");
- ZVAL_LONG(&params[2], 0x1f);
+ ZVAL_INT(&params[2], 0x1f);
}
if (call_user_function(CG(function_table), (zval*)NULL, &func, &retval, n, params TSRMLS_CC) == SUCCESS &&
Z_TYPE(retval) == IS_STRING) {
@@ -396,7 +396,7 @@ int make_http_soap_request(zval *this_ptr,
zval_ptr_dtor(&func);
// TODO: free retval ???
request = Z_STRVAL(retval);
- request_size = Z_STRLEN(retval);
+ request_size = Z_STRSIZE(retval);
} else {
zval_ptr_dtor(&params[0]);
zval_ptr_dtor(&func);
@@ -409,8 +409,8 @@ int make_http_soap_request(zval *this_ptr,
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket")-1)) != NULL) {
php_stream_from_zval_no_verify(stream,tmp);
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_use_proxy", sizeof("_use_proxy")-1)) != NULL && Z_TYPE_P(tmp) == IS_LONG) {
- use_proxy = Z_LVAL_P(tmp);
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_use_proxy", sizeof("_use_proxy")-1)) != NULL && Z_TYPE_P(tmp) == IS_INT) {
+ use_proxy = Z_IVAL_P(tmp);
}
} else {
stream = NULL;
@@ -427,9 +427,9 @@ int make_http_soap_request(zval *this_ptr,
if (context &&
(tmp = php_stream_context_get_option(context, "http", "max_redirects")) != NULL) {
- if (Z_TYPE_P(tmp) != IS_STRING || !is_numeric_string(Z_STRVAL_P(tmp), Z_STRLEN_P(tmp), &redirect_max, NULL, 1)) {
- if (Z_TYPE_P(tmp) == IS_LONG)
- redirect_max = Z_LVAL_P(tmp);
+ if (Z_TYPE_P(tmp) != IS_STRING || !is_numeric_string(Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp), &redirect_max, NULL, 1)) {
+ if (Z_TYPE_P(tmp) == IS_INT)
+ redirect_max = Z_IVAL_P(tmp);
}
}
@@ -504,7 +504,7 @@ try_again:
if (stream) {
php_stream_auto_cleanup(stream);
add_property_resource(this_ptr, "httpsocket", stream->res);
- add_property_long(this_ptr, "_use_proxy", use_proxy);
+ add_property_int(this_ptr, "_use_proxy", use_proxy);
} else {
php_url_free(phpurl);
if (request != buf) {efree(request);}
@@ -566,7 +566,7 @@ try_again:
}
if (!http_1_1 ||
((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_keep_alive", sizeof("_keep_alive")-1)) != NULL &&
- Z_LVAL_P(tmp) == 0)) {
+ Z_IVAL_P(tmp) == 0)) {
smart_str_append_const(&soap_headers, "\r\n"
"Connection: close\r\n");
} else {
@@ -575,17 +575,17 @@ try_again:
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_user_agent", sizeof("_user_agent")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- if (Z_STRLEN_P(tmp) > 0) {
+ if (Z_STRSIZE_P(tmp) > 0) {
smart_str_append_const(&soap_headers, "User-Agent: ");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
smart_str_append_const(&soap_headers, "\r\n");
}
} else if (context &&
(tmp = php_stream_context_get_option(context, "http", "user_agent")) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- if (Z_STRLEN_P(tmp) > 0) {
+ if (Z_STRSIZE_P(tmp) > 0) {
smart_str_append_const(&soap_headers, "User-Agent: ");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
smart_str_append_const(&soap_headers, "\r\n");
}
} else if (FG(user_agent)) {
@@ -615,7 +615,7 @@ try_again:
}
}
smart_str_append_const(&soap_headers,"Content-Length: ");
- smart_str_append_long(&soap_headers, request_size);
+ smart_str_append_int(&soap_headers, request_size);
smart_str_append_const(&soap_headers, "\r\n");
/* HTTP Authentication */
@@ -637,38 +637,38 @@ try_again:
make_digest(cnonce, hash);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "nc", sizeof("nc")-1)) != NULL &&
- Z_TYPE_P(tmp) == IS_LONG) {
- Z_LVAL_P(tmp)++;
- snprintf(nc, sizeof(nc), "%08ld", Z_LVAL_P(tmp));
+ Z_TYPE_P(tmp) == IS_INT) {
+ Z_IVAL_P(tmp)++;
+ snprintf(nc, sizeof(nc), "%08ld", Z_IVAL_P(tmp));
} else {
- add_assoc_long(digest, "nc", 1);
+ add_assoc_int(digest, "nc", 1);
strcpy(nc, "00000001");
}
PHP_MD5Init(&md5ctx);
- PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(login), Z_STRLEN_P(login));
+ PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(login), Z_STRSIZE_P(login));
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "realm", sizeof("realm")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
if ((password = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password")-1)) != NULL &&
Z_TYPE_P(password) == IS_STRING) {
- PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(password), Z_STRLEN_P(password));
+ PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(password), Z_STRSIZE_P(password));
}
PHP_MD5Final(hash, &md5ctx);
make_digest(HA1, hash);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "algorithm", sizeof("algorithm")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING &&
- Z_STRLEN_P(tmp) == sizeof("md5-sess")-1 &&
+ Z_STRSIZE_P(tmp) == sizeof("md5-sess")-1 &&
stricmp(Z_STRVAL_P(tmp), "md5-sess") == 0) {
PHP_MD5Init(&md5ctx);
PHP_MD5Update(&md5ctx, (unsigned char*)HA1, 32);
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "nonce", sizeof("nonce")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
PHP_MD5Update(&md5ctx, (unsigned char*)cnonce, 8);
@@ -692,7 +692,7 @@ try_again:
/*
if (zend_hash_find(Z_ARRVAL_PP(digest), "qop", sizeof("qop"), (void **)&tmp) == SUCCESS &&
Z_TYPE_PP(tmp) == IS_STRING &&
- Z_STRLEN_PP(tmp) == sizeof("auth-int")-1 &&
+ Z_STRSIZE_PP(tmp) == sizeof("auth-int")-1 &&
stricmp(Z_STRVAL_PP(tmp), "auth-int") == 0) {
PHP_MD5Update(&md5ctx, ":", 1);
PHP_MD5Update(&md5ctx, HEntity, HASHHEXLEN);
@@ -706,7 +706,7 @@ try_again:
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "nonce", sizeof("nonce")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
- PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ PHP_MD5Update(&md5ctx, (unsigned char*)Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
PHP_MD5Update(&md5ctx, (unsigned char*)":", 1);
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "qop", sizeof("qop")-1)) != NULL &&
@@ -724,16 +724,16 @@ try_again:
make_digest(response, hash);
smart_str_append_const(&soap_headers, "Authorization: Digest username=\"");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(login), Z_STRLEN_P(login));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(login), Z_STRSIZE_P(login));
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "realm", sizeof("realm")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_append_const(&soap_headers, "\", realm=\"");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "nonce", sizeof("nonce")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_append_const(&soap_headers, "\", nonce=\"");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
smart_str_append_const(&soap_headers, "\", uri=\"");
if (phpurl->path) {
@@ -763,12 +763,12 @@ try_again:
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "opaque", sizeof("opaque")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_append_const(&soap_headers, "\", opaque=\"");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(digest), "algorithm", sizeof("algorithm")-1)) != NULL &&
Z_TYPE_P(tmp) == IS_STRING) {
smart_str_append_const(&soap_headers, "\", algorithm=\"");
- smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRLEN_P(tmp));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(tmp), Z_STRSIZE_P(tmp));
}
smart_str_append_const(&soap_headers, "\"\r\n");
}
@@ -776,11 +776,11 @@ try_again:
zend_string *buf;
smart_str auth = {0};
- smart_str_appendl(&auth, Z_STRVAL_P(login), Z_STRLEN_P(login));
+ smart_str_appendl(&auth, Z_STRVAL_P(login), Z_STRSIZE_P(login));
smart_str_appendc(&auth, ':');
if ((password = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "_password", sizeof("_password")-1)) != NULL &&
Z_TYPE_P(password) == IS_STRING) {
- smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRLEN_P(password));
+ smart_str_appendl(&auth, Z_STRVAL_P(password), Z_STRSIZE_P(password));
}
smart_str_0(&auth);
buf = php_base64_encode((unsigned char*)auth.s->val, auth.s->len);
@@ -819,13 +819,13 @@ try_again:
Z_TYPE_P(value) == IS_STRING) {
zval *tmp;
if (((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 1)) == NULL ||
- strncmp(phpurl->path?phpurl->path:"/",Z_STRVAL_P(tmp),Z_STRLEN_P(tmp)) == 0) &&
+ strncmp(phpurl->path?phpurl->path:"/",Z_STRVAL_P(tmp),Z_STRSIZE_P(tmp)) == 0) &&
((tmp = zend_hash_index_find(Z_ARRVAL_P(data), 2)) == NULL ||
in_domain(phpurl->host,Z_STRVAL_P(tmp))) &&
(use_ssl || (tmp = zend_hash_index_find(Z_ARRVAL_P(data), 3)) == NULL)) {
smart_str_appendl(&soap_headers, key->val, key->len);
smart_str_appendc(&soap_headers, '=');
- smart_str_appendl(&soap_headers, Z_STRVAL_P(value), Z_STRLEN_P(value));
+ smart_str_appendl(&soap_headers, Z_STRVAL_P(value), Z_STRSIZE_P(value));
smart_str_appendc(&soap_headers, ';');
}
}
@@ -841,7 +841,7 @@ try_again:
smart_str_append_const(&soap_headers, "\r\n");
smart_str_0(&soap_headers);
if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL &&
- Z_LVAL_P(trace) > 0) {
+ Z_IVAL_P(trace) > 0) {
add_property_stringl(this_ptr, "__last_request_headers", soap_headers.s->val, soap_headers.s->len);
}
smart_str_appendl(&soap_headers, request, request_size);
@@ -886,7 +886,7 @@ try_again:
}
if ((trace = zend_hash_str_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace")-1)) != NULL &&
- Z_LVAL_P(trace) > 0) {
+ Z_IVAL_P(trace) > 0) {
add_property_stringl(this_ptr, "__last_response_headers", http_headers, http_header_size);
}
@@ -1283,9 +1283,9 @@ try_again:
if (http_status >= 400) {
int error = 0;
- if (Z_STRLEN_P(return_value) == 0) {
+ if (Z_STRSIZE_P(return_value) == 0) {
error = 1;
- } else if (Z_STRLEN_P(return_value) > 0) {
+ } else if (Z_STRSIZE_P(return_value) > 0) {
if (!content_type_xml) {
char *s = Z_STRVAL_P(return_value);