@@ -71,6 +71,7 @@ public function add(
71
71
}
72
72
73
73
// curlopt3: Finally, hard-code these curlopt settings:
74
+ $ curl ->setOpt (CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
74
75
$ curl ->setOpt (CURLOPT_RETURNTRANSFER , false );
75
76
$ curl ->setOpt (CURLOPT_HEADER , false );
76
77
$ curl ->setOpt (CURLOPT_HEADERFUNCTION , $ this ->writeHeader (...));
@@ -102,6 +103,8 @@ public function tick():void {
102
103
foreach ($ this ->curlMultiList as $ i => $ curlMulti ) {
103
104
$ active = 0 ;
104
105
106
+ // 1) This first do-while loop initiates all underlying curl handles, but on
107
+ // slow networks, this might not be enough to download all responses...
105
108
do {
106
109
$ status = $ curlMulti ->exec ($ active );
107
110
}
@@ -127,6 +130,19 @@ public function tick():void {
127
130
$ response = null ;
128
131
$ this ->deferredList [$ i ] = null ;
129
132
}
133
+ else {
134
+ while ($ active && $ status === CURLM_OK ) {
135
+ // 2) We must wait for network activity, because there may be no activity
136
+ // between us starting the request and checking the response, especially with
137
+ // slow servers.
138
+ if ($ curlMulti ->select () !== -1 ) {
139
+ do {
140
+ $ status = $ curlMulti ->exec ($ active );
141
+ }
142
+ while ($ status === CURLM_CALL_MULTI_PERFORM );
143
+ }
144
+ }
145
+ }
130
146
}
131
147
132
148
if ($ totalActive === 0 ) {
0 commit comments