diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 5bd1b479e21f8..780592b1850f5 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2371,6 +2371,19 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu int type; void * what; + /* If a NULL was supplied together with INFILE, reset the default if we're still at direct i/o and don't have a user-function for read */ + /* TODO: Allow setting to NULL for other combinations */ + if(Z_TYPE_PP(zvalue) == IS_NULL && option == CURLOPT_INFILE && ch->handlers->read->method == PHP_CURL_DIRECT) { + if(ch->handlers->read->stream != NULL) { + zval_ptr_dtor(&ch->handlers->read->stream); + } + ch->handlers->read->fd = 0; + ch->handlers->read->fp = 0; + ch->handlers->read->stream = NULL; + error = curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); + break; + } + what = zend_fetch_resource(zvalue TSRMLS_CC, -1, "File-Handle", &type, 1, php_file_le_stream(), php_file_le_pstream()); if (!what) { RETVAL_FALSE;