@@ -159,11 +159,8 @@ protected function requestMulti(
159
159
$ urlCount = \count ($ urls );
160
160
$ bodyCount = \count ($ bodies );
161
161
162
- if (
163
- $ urlCount != $ bodyCount &&
164
- ($ urlCount == 1 && $ bodyCount != 1 || $ urlCount != 1 && $ bodyCount == 1 )
165
- ) {
166
- throw new \Exception ('URL and body counts must be equal or 1. ' );
162
+ if (!($ urlCount == $ bodyCount || $ urlCount == 1 || $ bodyCount == 1 )) {
163
+ throw new \Exception ('URL and body counts must be equal or one must equal 1. ' );
167
164
}
168
165
169
166
if ($ urlCount > $ bodyCount ) {
@@ -172,13 +169,13 @@ protected function requestMulti(
172
169
$ urls = \array_pad ($ urls , $ bodyCount , $ urls [0 ]);
173
170
}
174
171
175
- foreach ( \array_combine ( $ urls , $ bodies ) as $ url => $ body ) {
176
- if (!empty ($ body )) {
177
- $ headers [] = 'Content-Length: ' .\strlen ($ body );
172
+ for ( $ i = 0 ; $ i < \count ( $ urls ); $ i ++ ) {
173
+ if (!empty ($ bodies [ $ i ] )) {
174
+ $ headers [] = 'Content-Length: ' .\strlen ($ bodies [ $ i ] );
178
175
}
179
176
180
- \curl_setopt ($ ch , CURLOPT_URL , $ url );
181
- \curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ body );
177
+ \curl_setopt ($ ch , CURLOPT_URL , $ urls [ $ i ] );
178
+ \curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ bodies [ $ i ] );
182
179
\curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers );
183
180
\curl_multi_add_handle ($ mh , \curl_copy_handle ($ ch ));
184
181
}
0 commit comments