summaryrefslogtreecommitdiff
path: root/modules/simpletest/drupal_web_test_case.php
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-12-03 14:51:53 +0000
committerDries Buytaert <dries@buytaert.net>2008-12-03 14:51:53 +0000
commit5c72eb294ab1527b8da1b261cfbffeeb7ff98c9f (patch)
treeb9716286f5c8e36b77680ea0e917f5f17620b82f /modules/simpletest/drupal_web_test_case.php
parent3aaffd3364087dfcf6d2c77ffe8c7496929a09d3 (diff)
downloadbrdo-5c72eb294ab1527b8da1b261cfbffeeb7ff98c9f.tar.gz
brdo-5c72eb294ab1527b8da1b261cfbffeeb7ff98c9f.tar.bz2
- Patch #327269 by c960657: when drupal_page_cache_header() compares the client's If-Modified-Since header to $cache->created, it assumed a certain date format. However, HTTP/1.1 allows several variations of the date format, i.e. the same time may be represented in slightly different ways. If the client sends the date in a different format than the one generated by Drupal, it would never receive a 304 Not Modified response. Also added a good amount of tests for the drupal_page_cache_header() code.
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r--modules/simpletest/drupal_web_test_case.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 6ebf9d8df..b0f2e9f40 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1001,16 +1001,19 @@ class DrupalWebTestCase {
* Drupal path or URL to load into internal browser
* @param $options
* Options to be forwarded to url().
+ * @param $headers
+ * An array containing additional HTTP request headers, each formatted as
+ * "name: value".
* @return
* The retrieved HTML string, also available as $this->drupalGetContent()
*/
- protected function drupalGet($path, $options = array()) {
+ protected function drupalGet($path, Array $options = array(), Array $headers = array()) {
$options['absolute'] = TRUE;
// We re-using a CURL connection here. If that connection still has certain
// options set, it might change the GET into a POST. Make sure we clear out
// previous options.
- $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_NOBODY => FALSE));
+ $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => $headers));
$this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
// Replace original page output with new output from redirected page(s).
@@ -1051,8 +1054,11 @@ class DrupalWebTestCase {
* Value of the submit button.
* @param $options
* Options to be forwarded to url().
+ * @param $headers
+ * An array containing additional HTTP request headers, each formatted as
+ * "name: value".
*/
- protected function drupalPost($path, $edit, $submit, $options = array()) {
+ protected function drupalPost($path, $edit, $submit, Array $options = array(), Array $headers = array()) {
$submit_matches = FALSE;
if (isset($path)) {
$html = $this->drupalGet($path, $options);
@@ -1092,7 +1098,7 @@ class DrupalWebTestCase {
}
$post = implode('&', $post);
}
- $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post));
+ $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HTTPHEADER => $headers));
// Ensure that any changes to variables in the other thread are picked up.
$this->refreshVariables();
@@ -1141,12 +1147,15 @@ class DrupalWebTestCase {
* Drupal path or URL to load into internal browser
* @param $options
* Options to be forwarded to url().
+ * @param $headers
+ * An array containing additional HTTP request headers, each formatted as
+ * "name: value".
* @return
* The retrieved headers, also available as $this->drupalGetContent()
*/
- protected function drupalHead($path, Array $options = array()) {
+ protected function drupalHead($path, Array $options = array(), Array $headers = array()) {
$options['absolute'] = TRUE;
- $out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => url($path, $options)));
+ $out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_HTTPHEADER => $headers));
$this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
return $out;
}