/**
  * send http post request
  *
  * @param string $url
  * @param array $fields data send by the request
  * @return bool
  */
 public function post($url, array $fields)
 {
     $fieldsString = $this->assemblePostParameters($fields);
     $certBundle = $this->certificateManager->getCertificateBundle();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, (string) $fieldsString);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     if (is_readable($certBundle)) {
         curl_setopt($ch, CURLOPT_CAINFO, $certBundle);
     }
     $result = curl_exec($ch);
     $success = $result ? true : false;
     curl_close($ch);
     return array('success' => $success, 'result' => $result);
 }
Exemple #2
0
 function testGetCertificateBundle()
 {
     $this->assertSame('/' . $this->username . '/files_external/rootcerts.crt', $this->certificateManager->getCertificateBundle());
 }