diff --git a/httprl.module b/httprl.module index e25a580..d953d2c 100644 --- a/httprl.module +++ b/httprl.module @@ -123,6 +123,8 @@ function httprl_build_url_self($path = '', $detect_schema = FALSE) { * - context: A context resource created with stream_context_create(). * - blocking: set to FALSE to make this not care about the returned data. * - version: HTTP Version 1.0 or 1.1. Default is 1.0 for a good reason. + * - referrer: TRUE - send current page; FALSE - do not send current + * page. Default is FALSE. * @return bool * return value from httprl_send_request(). */ @@ -162,6 +164,7 @@ function httprl_request($url, $options = array()) { 'context' => NULL, 'blocking' => TRUE, 'version' => 1.0, + 'referrer' => FALSE, ); // stream_socket_client() requires timeout to be a float. @@ -264,8 +267,10 @@ function httprl_request($url, $options = array()) { $options['headers'] += array( 'User-Agent' => 'Drupal (+http://drupal.org/)', 'Connection' => 'close', - 'Referer' => $base_root . request_uri(), ); + if (!isset($options['headers']['Referer'] && !empty($options['referrer']))) { + $options['headers']['Referer'] = $base_root . request_uri(); + } // Only add Content-Length if we actually have any content or if it is a POST // or PUT request. Some non-standard servers get confused by Content-Length in