private function makeRequestList(array $urls)
 {
     $request = array();
     foreach ($urls as $url) {
         $request = new Request($url);
         $request->setOption(CURLOPT_RETURNTRANSFER, true);
         $requests[] = $request;
     }
     return $requests;
 }
Beispiel #2
0
 /**
  * Populate the POSTFIELDS option
  *
  * @param CurlRequest $curl cURL request object
  * @param Request $request the Request object we're populating
  */
 protected function setPostFields(CurlRequest $curl, HttpRequest $request)
 {
     $postfields = null;
     $content = $request->getContent();
     if (!empty($content)) {
         $postfields = $content;
         $a = 1;
     } else {
         if (count($request->files)) {
             // Add files to postfields as curl resources
             foreach ($request->files->all() as $key => $file) {
                 $file = $this->createCurlFile($file->getRealPath(), $file->getMimeType(), basename($file->getClientOriginalName()));
                 $request->request->set($key, $file);
             }
             $postfields = $request->request->all();
             // we need to manually set content-type
             $request->headers->set('Content-Type', "multipart/form-data");
             $a = 2;
         } else {
             if (count($request->request)) {
                 $postfields = http_build_query($request->request->all());
                 $a = 3;
             } else {
                 return;
             }
         }
     }
     if (is_string($postfields)) {
         $curl->setOption(CURLOPT_POSTFIELDS, $postfields);
         $request->headers->set('content-length', strlen($postfields));
     } else {
         $curl->setOption(CURLOPT_POSTFIELDS, $postfields);
     }
 }
 /**
  * Populate the POSTFIELDS option
  *
  * @param CurlRequest $curl cURL request object
  * @param Request $request the Request object we're populating
  */
 private function setPostFields(CurlRequest $curl, Request $request)
 {
     $postfields = null;
     $content = $request->getContent();
     if (!empty($content)) {
         $postfields = $content;
     } else {
         if (count($request->request->all()) > 0) {
             $postfields = http_build_query($request->request->all());
         }
     }
     $curl->setOption(CURLOPT_POSTFIELDS, $postfields);
 }