File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Test CURL_READFUNC_PAUSE and curl_pause()
3
+ --EXTENSIONS--
4
+ curl
5
+ --FILE--
6
+ <?php
7
+ include 'server.inc ' ;
8
+ $ host = curl_cli_server_start ();
9
+
10
+ class Input {
11
+ private static $ RESPONSES = [
12
+ 'Foo bar ' ,
13
+ CURL_READFUNC_PAUSE ,
14
+ 'baz qux ' ,
15
+ null
16
+ ];
17
+ private int $ res = 0 ;
18
+ public function __invoke ($ ch , $ hReadHandle , $ iMaxOut )
19
+ {
20
+ return self ::$ RESPONSES [$ this ->res ++];
21
+ }
22
+ }
23
+
24
+ $ inputHandle = fopen (__FILE__ , 'r ' );
25
+
26
+ $ ch = curl_init ();
27
+ curl_setopt ($ ch , CURLOPT_URL , "{$ host }/get.inc?test=input " );
28
+ curl_setopt ($ ch , CURLOPT_UPLOAD , 1 );
29
+ curl_setopt ($ ch , CURLOPT_READFUNCTION , new Input );
30
+ curl_setopt ($ ch , CURLOPT_INFILE , $ inputHandle );
31
+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
32
+
33
+ $ mh = curl_multi_init ();
34
+ curl_multi_add_handle ($ mh , $ ch );
35
+ do {
36
+ $ status = curl_multi_exec ($ mh , $ active );
37
+ curl_pause ($ ch , CURLPAUSE_CONT );
38
+ if ($ active ) {
39
+ usleep (100 );
40
+ curl_multi_select ($ mh );
41
+ }
42
+ } while ($ active && $ status == CURLM_OK );
43
+
44
+ echo curl_multi_getcontent ($ ch );
45
+ ?>
46
+ --EXPECT--
47
+ string(15) "Foo bar baz qux"
Original file line number Diff line number Diff line change 4
4
case 'post ' :
5
5
var_dump ($ _POST );
6
6
break ;
7
+ case 'input ' :
8
+ var_dump (file_get_contents ('php://input ' ));
9
+ break ;
7
10
case 'getpost ' :
8
11
var_dump ($ _GET );
9
12
var_dump ($ _POST );
You can’t perform that action at this time.
0 commit comments