protected function DrupalWebTestCase::curlExec in SimpleTest 7
Same name and namespace in other branches
- 6.2 drupal_web_test_case.php \DrupalWebTestCase::curlExec()
- 7.2 drupal_web_test_case.php \DrupalWebTestCase::curlExec()
Performs a cURL exec with the specified options after calling curlConnect().
Parameters
$curl_options: Custom cURL options.
Return value
Content returned from the exec.
3 calls to DrupalWebTestCase::curlExec()
- DrupalWebTestCase::drupalGet in ./
drupal_web_test_case.php - Retrieves a Drupal path or an absolute path.
- DrupalWebTestCase::drupalHead in ./
drupal_web_test_case.php - Retrieves only the headers for a Drupal path or an absolute path.
- DrupalWebTestCase::drupalPost in ./
drupal_web_test_case.php - Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
File
- ./
drupal_web_test_case.php, line 1264
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
Code
protected function curlExec($curl_options) {
$this
->curlInitialize();
$url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL];
if (!empty($curl_options[CURLOPT_POST])) {
// This is a fix for the Curl library to prevent Expect: 100-continue
// headers in POST requests, that may cause unexpected HTTP response
// codes from some webservers (like lighttpd that returns a 417 error
// code). It is done by setting an empty "Expect" header field that is
// not overwritten by Curl.
$curl_options[CURLOPT_HTTPHEADER][] = 'Expect:';
}
curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
// Reset headers and the session ID.
$this->session_id = NULL;
$this->headers = array();
$this
->drupalSetContent(curl_exec($this->curlHandle), curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL));
$message_vars = array(
'!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
'@url' => $url,
'@status' => curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE),
'!length' => format_size(strlen($this->content)),
);
$message = t('!method @url returned @status (!length).', $message_vars);
$this
->assertTrue($this->content !== FALSE, $message, t('Browser'));
return $this
->drupalGetContent();
}