$now = gmdate('D, d M Y H:i:s') . ' GMT';
// Send HTTP header
- sendHeader('HTTP/1.1 ' . getHttpStatus());
+ addHttpHeader('HTTP/1.1 ' . getHttpStatus());
// General headers for no caching
- sendHeader('Expires: ' . $now); // RFC2616 - Section 14.21
- sendHeader('Last-Modified: ' . $now);
- sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
- sendHeader('Pragma: no-cache'); // HTTP/1.0
- sendHeader('Connection: Close');
- sendHeader('Content-Type: ' . getContentType() . '; charset=UTF-8');
- sendHeader('Content-Language: ' . getLanguage());
+ addHttpHeader('Expires: ' . $now); // RFC2616 - Section 14.21
+ addHttpHeader('Last-Modified: ' . $now);
+ addHttpHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
+ addHttpHeader('Pragma: no-cache'); // HTTP/1.0
+ addHttpHeader('Connection: Close');
+ addHttpHeader('Content-Type: ' . getContentType() . '; charset=UTF-8');
+ addHttpHeader('Content-Language: ' . getLanguage());
}
// Checks wether the URL is full-qualified (http[s]:// + hostname [+ request data])
return $host;
}
+// Adds a HTTP header to array
+function addHttpHeader ($header) {
+ // Send the header
+ //* DEBUG: */ logDebugMessage(__FUNCTION__ . ': header=' . $header);
+ $GLOBALS['http_header'][] = trim($header);
+}
+
+// Flushes all HTTP headers
+function flushHttpHeaders () {
+ // Is the header already sent?
+ if (headers_sent()) {
+ // Then abort here
+ debug_report_bug(__FUNCTION__, __LINE__, 'Headers already sent!');
+ } // END - if
+
+ // Flush all headers if found
+ if ((isset($GLOBALS['http_header'])) && (is_array($GLOBALS['http_header']))) {
+ foreach ($GLOBALS['http_header'] as $header) {
+ header($header);
+ } // END - foreach
+ } // END - if
+
+ // Mark them as flushed
+ $GLOBALS['http_header'] = array();
+}
+
// [EOF]
?>