-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PHP curl request return with error #11197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Does it consistently fail on a newer version, and consistently work on an older version? What is the version number of the older version you tried? What's the curl version on your system? |
I Run same code in older PHP version 8.2.1 but not shown any error like this. Is there any other configuration? |
Details
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 66f19f0def..2dd4a7bf65 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -60,6 +60,13 @@
#include "ext/standard/file.h"
#include "ext/standard/url.h"
#include "curl_private.h"
+
+#ifdef __GNUC__
+/* don't complain about deprecated CURLOPT_* we're exposing to PHP; we
+ need to keep using those to avoid breaking PHP API compatibiltiy */
+# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
#include "curl_arginfo.h"
#ifdef PHP_CURL_NEED_OPENSSL_TSL /* {{{ */
@@ -805,6 +812,8 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
if (Z_TYPE(retval) == IS_STRING) {
length = MIN((int) (size * nmemb), Z_STRLEN(retval));
memcpy(data, Z_STRVAL(retval), length);
+ } else if (Z_TYPE(retval) == IS_LONG) {
+ length = Z_LVAL_P(&retval);
}
zval_ptr_dtor(&retval);
}
@@ -1372,7 +1381,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
postval = Z_STR_P(prop);
if (php_check_open_basedir(ZSTR_VAL(postval))) {
- return 1;
+ return FAILURE;
}
prop = zend_read_property(curl_CURLFile_class, Z_OBJ_P(current), "mime", sizeof("mime")-1, 0, &rv);
diff --git a/ext/curl/tests/CONFLICTS b/ext/curl/tests/CONFLICTS
new file mode 100644
index 0000000000..13368f8290
--- /dev/null
+++ b/ext/curl/tests/CONFLICTS
@@ -0,0 +1 @@
+curl
diff --git a/ext/curl/tests/curl_pause_001.phpt b/ext/curl/tests/curl_pause_001.phpt
new file mode 100644
index 0000000000..1fce0dd4af
--- /dev/null
+++ b/ext/curl/tests/curl_pause_001.phpt
@@ -0,0 +1,47 @@
+--TEST--
+Test CURL_READFUNC_PAUSE and curl_pause()
+--EXTENSIONS--
+curl
+--FILE--
+<?php
+include 'server.inc';
+$host = curl_cli_server_start();
+
+class Input {
+ private static $RESPONSES = [
+ 'Foo bar ',
+ CURL_READFUNC_PAUSE,
+ 'baz qux',
+ null
+ ];
+ private int $res = 0;
+ public function __invoke($ch, $hReadHandle, $iMaxOut)
+ {
+ return self::$RESPONSES[$this->res++];
+ }
+}
+
+$inputHandle = fopen(__FILE__, 'r');
+
+$ch = curl_init();
+curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=input");
+curl_setopt($ch, CURLOPT_UPLOAD, 1);
+curl_setopt($ch, CURLOPT_READFUNCTION, new Input);
+curl_setopt($ch, CURLOPT_INFILE, $inputHandle);
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
+$mh = curl_multi_init();
+curl_multi_add_handle($mh, $ch);
+do {
+ $status = curl_multi_exec($mh, $active);
+ curl_pause($ch, CURLPAUSE_CONT);
+ if ($active) {
+ usleep(100);
+ curl_multi_select($mh);
+ }
+} while ($active && $status == CURLM_OK);
+
+echo curl_multi_getcontent($ch);
+?>
+--EXPECT--
+string(15) "Foo bar baz qux"
diff --git a/ext/curl/tests/curl_version_basic_001.phpt b/ext/curl/tests/curl_version_basic_001.phpt
index 6bc361bade..52652822a3 100644
--- a/ext/curl/tests/curl_version_basic_001.phpt
+++ b/ext/curl/tests/curl_version_basic_001.phpt
@@ -22,6 +22,6 @@
int(%i)
string(%i) "%s"
string(%i) "%s"
-string(%i) "%s"
-string(%i) "%s"
+string(%i) "%S"
+string(%i) "%S"
bool(true)
diff --git a/ext/curl/tests/responder/get.inc b/ext/curl/tests/responder/get.inc
index 4ed9ae0282..c139c8c7d4 100644
--- a/ext/curl/tests/responder/get.inc
+++ b/ext/curl/tests/responder/get.inc
@@ -4,6 +4,9 @@
case 'post':
var_dump($_POST);
break;
+ case 'input':
+ var_dump(file_get_contents('php://input'));
+ break;
case 'getpost':
var_dump($_GET);
var_dump($_POST); Doesn't look like there's anything relevant in that diff. What happens if you set |
No feedback was provided. The issue is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so. Thank you. |
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
8.2.4
Operating System
22.04
The text was updated successfully, but these errors were encountered: