original_string: protected function multi($requests, $options = array()) {
          $count   = count($requests);
          $handles = array();
          $results = array();
          $main    = curl_multi_init();
          for ($i = 0; $i < $count; $i++) {
              if (!empty($requests[$i]['filepath']) and empty($requests[$i]['file'])) {
                  // open file
                  $requests[$i]['file'] = fopen($requests[$i]['filepath'], 'w');
                  $requests[$i]['auto-handle'] = true;
              }
              foreach($requests[$i] as $n=>$v) {
                  $options[$n] = $v;
              }
              $handles[$i] = curl_init($requests[$i]['url']);
              $this->apply_opt($handles[$i], $options);
              curl_multi_add_handle($main, $handles[$i]);
          }
          $running = 0;
          do {
              curl_multi_exec($main, $running);
          } while($running > 0);
          for ($i = 0; $i < $count; $i++) {
              if (!empty($options['CURLOPT_RETURNTRANSFER'])) {
                  $results[] = true;
              } else {
                  $results[] = curl_multi_getcontent($handles[$i]);
              }
              curl_multi_remove_handle($main, $handles[$i]);
          }
          curl_multi_close($main);
  
          for ($i = 0; $i < $count; $i++) {
              if (!empty($requests[$i]['filepath']) and !empty($requests[$i]['auto-handle'])) {
                  // close file handler if file is opened in this function
                  fclose($requests[$i]['file']);
              }
          }
          return $results;
      }
code: protected function multi($requests, $options = array()) {
          $count   = count($requests);
          $handles = array();
          $results = array();
          $main    = curl_multi_init();
          for ($i = 0; $i < $count; $i++) {
              if (!empty($requests[$i]['filepath']) and empty($requests[$i]['file'])) {
                  // open file
                  $requests[$i]['file'] = fopen($requests[$i]['filepath'], 'w');
                  $requests[$i]['auto-handle'] = true;
              }
              foreach($requests[$i] as $n=>$v) {
                  $options[$n] = $v;
              }
              $handles[$i] = curl_init($requests[$i]['url']);
              $this->apply_opt($handles[$i], $options);
              curl_multi_add_handle($main, $handles[$i]);
          }
          $running = 0;
          do {
              curl_multi_exec($main, $running);
          } while($running > 0);
          for ($i = 0; $i < $count; $i++) {
              if (!empty($options['CURLOPT_RETURNTRANSFER'])) {
                  $results[] = true;
              } else {
                  $results[] = curl_multi_getcontent($handles[$i]);
              }
              curl_multi_remove_handle($main, $handles[$i]);
          }
          curl_multi_close($main);
  
          for ($i = 0; $i < $count; $i++) {
              if (!empty($requests[$i]['filepath']) and !empty($requests[$i]['auto-handle'])) {
                  // close file handler if file is opened in this function
                  fclose($requests[$i]['file']);
              }
          }
          return $results;
      }
code_tokens: protected function multi ( $ requests , $ options = array ( ) ) { $ count = count ( $ requests ) ; $ handles = array ( ) ; $ results = array ( ) ; $ main = curl_multi_init ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( ! empty ( $ requests [ $ i ] [ 'filepath' ] ) and empty ( $ requests [ $ i ] [ 'file' ] ) ) { // open file $ requests [ $ i ] [ 'file' ] = fopen ( $ requests [ $ i ] [ 'filepath' ] , 'w' ) ; $ requests [ $ i ] [ 'auto-handle' ] = true ; } foreach ( $ requests [ $ i ] as $ n => $ v ) { $ options [ $ n ] = $ v ; } $ handles [ $ i ] = curl_init ( $ requests [ $ i ] [ 'url' ] ) ; $ this -> apply_opt ( $ handles [ $ i ] , $ options ) ; curl_multi_add_handle ( $ main , $ handles [ $ i ] ) ; } $ running = 0 ; do { curl_multi_exec ( $ main , $ running ) ; } while ( $ running > 0 ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( ! empty ( $ options [ 'CURLOPT_RETURNTRANSFER' ] ) ) { $ results [ ] = true ; } else { $ results [ ] = curl_multi_getcontent ( $ handles [ $ i ] ) ; } curl_multi_remove_handle ( $ main , $ handles [ $ i ] ) ; } curl_multi_close ( $ main ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( ! empty ( $ requests [ $ i ] [ 'filepath' ] ) and ! empty ( $ requests [ $ i ] [ 'auto-handle' ] ) ) { // close file handler if file is opened in this function fclose ( $ requests [ $ i ] [ 'file' ] ) ; } } return $ results ; }
docstring: Multi HTTP Requests
  This function could run multi-requests in parallel.
  
  @param array $requests An array of files to request
  @param array $options An array of options to set
  @return array An array of results
docstring_tokens: Multi HTTP Requests This function could run multi - requests in parallel .