mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
ext/curl: Various minor clean-up refactorings (#18042)
This commit is contained in:
parent
c5f6a8b0a2
commit
d8e7f362dd
3 changed files with 8 additions and 17 deletions
|
@ -843,7 +843,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
|
|||
{
|
||||
php_curl *ch = (php_curl *)ctx;
|
||||
php_curl_read *read_handler = ch->handlers.read;
|
||||
int length = 0;
|
||||
size_t length = 0;
|
||||
|
||||
switch (read_handler->method) {
|
||||
case PHP_CURL_DIRECT:
|
||||
|
@ -1184,7 +1184,6 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
|
|||
|
||||
array_init(&certhash);
|
||||
for (slist = ci->certinfo[i]; slist; slist = slist->next) {
|
||||
int len;
|
||||
char s[64];
|
||||
char *tmp;
|
||||
strncpy(s, slist->data, sizeof(s));
|
||||
|
@ -1192,7 +1191,7 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
|
|||
tmp = memchr(s, ':', sizeof(s));
|
||||
if(tmp) {
|
||||
*tmp = '\0';
|
||||
len = strlen(s);
|
||||
size_t len = strlen(s);
|
||||
add_assoc_string(&certhash, s, &slist->data[len+1]);
|
||||
} else {
|
||||
php_error_docref(NULL, E_WARNING, "Could not extract hash key from certificate info");
|
||||
|
@ -1445,7 +1444,6 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
|
|||
zval *prop, rv;
|
||||
char *type = NULL, *filename = NULL;
|
||||
struct mime_data_cb_arg *cb_arg;
|
||||
php_stream *stream;
|
||||
php_stream_statbuf ssb;
|
||||
size_t filesize = -1;
|
||||
curl_seek_callback seekfunc = seek_cb;
|
||||
|
@ -1475,6 +1473,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
|
|||
zval_ptr_dtor(&ch->postfields);
|
||||
ZVAL_COPY(&ch->postfields, zpostfields);
|
||||
|
||||
php_stream *stream;
|
||||
if ((stream = php_stream_open_wrapper(ZSTR_VAL(postval), "rb", STREAM_MUST_SEEK, NULL))) {
|
||||
if (!stream->readfilters.head && !php_stream_stat(stream, &ssb)) {
|
||||
filesize = ssb.sb.st_size;
|
||||
|
@ -2409,7 +2408,7 @@ PHP_FUNCTION(curl_setopt_array)
|
|||
ch = Z_CURL_P(zid);
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(arr), option, string_key, entry) {
|
||||
if (string_key) {
|
||||
if (UNEXPECTED(string_key)) {
|
||||
zend_argument_value_error(2, "contains an invalid cURL option");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea
|
|||
php_curl *ch;
|
||||
php_curl *parent;
|
||||
php_curlm *mh = (php_curlm *)userp;
|
||||
size_t rval = CURL_PUSH_DENY;
|
||||
int rval = CURL_PUSH_DENY;
|
||||
zval *pz_parent_ch = NULL;
|
||||
zval pz_ch;
|
||||
zval headers;
|
||||
|
@ -524,11 +524,7 @@ PHP_FUNCTION(curl_multi_setopt)
|
|||
|
||||
mh = Z_CURL_MULTI_P(z_mh);
|
||||
|
||||
if (_php_curl_multi_setopt(mh, options, zvalue, return_value)) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETURN_BOOL(_php_curl_multi_setopt(mh, options, zvalue, return_value));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ PHP_FUNCTION(curl_share_close)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static bool _php_curl_share_setopt(php_curlsh *sh, zend_long option, zval *zvalue, zval *return_value) /* {{{ */
|
||||
static bool _php_curl_share_setopt(php_curlsh *sh, zend_long option, const zval *zvalue) /* {{{ */
|
||||
{
|
||||
CURLSHcode error = CURLSHE_OK;
|
||||
|
||||
|
@ -91,11 +91,7 @@ PHP_FUNCTION(curl_share_setopt)
|
|||
|
||||
sh = Z_CURL_SHARE_P(z_sh);
|
||||
|
||||
if (_php_curl_share_setopt(sh, options, zvalue, return_value)) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETURN_BOOL(_php_curl_share_setopt(sh, options, zvalue));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue