N°3317 - Add http headers

This commit is contained in:
Eric
2020-09-22 11:39:19 +02:00
parent c6df0b6d7d
commit 1453558f3e
12 changed files with 35 additions and 9 deletions

View File

@@ -41,7 +41,9 @@ class ajax_page extends WebPage implements iTabbedPage
parent::__construct($s_title, $bPrintable);
$this->m_sReadyScript = "";
//$this->add_header("Content-type: text/html; charset=utf-8");
$this->add_header("Cache-control: no-cache");
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
$this->m_oTabs = new TabManager();
$this->sContentType = 'text/html';
$this->sContentDisposition = 'inline';

View File

@@ -33,7 +33,9 @@ class CSVPage extends WebPage
{
parent::__construct($s_title);
$this->add_header("Content-type: text/plain; charset=".self::PAGES_CHARSET);
$this->add_header("Cache-control: no-cache");
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
//$this->add_header("Content-Transfer-Encoding: binary");
}

View File

@@ -71,7 +71,9 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
$this->m_aMessages = array();
$this->SetRootUrl(utils::GetAbsoluteUrlAppRoot());
$this->add_header("Content-type: text/html; charset=".self::PAGES_CHARSET);
$this->add_header("Cache-control: no-cache");
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
$this->add_linked_stylesheet("../css/jquery.treeview.css");
$this->add_linked_stylesheet("../css/jquery.autocomplete.css");
$this->add_linked_stylesheet("../css/jquery-ui-timepicker-addon.css");

View File

@@ -85,7 +85,9 @@ class LoginWebPage extends NiceWebPage
parent::__construct($sTitle);
$this->SetStyleSheet();
$this->add_header("Cache-control: no-cache");
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
}
public function SetStyleSheet()

View File

@@ -487,8 +487,9 @@ class WebPage implements Page
*/
public function no_cache()
{
$this->add_header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
$this->add_header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
}
/**

View File

@@ -43,7 +43,9 @@ class XMLPage extends WebPage
$this->m_bPassThrough = $bPassThrough;
$this->m_bHeaderSent = false;
$this->add_header("Content-type: text/xml; charset=".self::PAGES_CHARSET);
$this->add_header("Cache-control: no-cache");
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
$this->add_header("Content-location: export.xml");
}

View File

@@ -5,8 +5,10 @@ class HubConnectorPage extends NiceWebPage
public function __construct($sTitle)
{
parent::__construct($sTitle);
$this->add_header("Cache-control: no-cache");
$this->add_header('Cache-control: no-cache, no-store, must-revalidate');
$this->add_header('Pragma: no-cache');
$this->add_header('Expires: 0');
$sImagesDir = utils::GetAbsoluteUrlAppRoot().'images';
$sModuleImagesDir = utils::GetAbsoluteUrlModulesRoot().'itop-hub-connector/images';

View File

@@ -1962,6 +1962,7 @@ EOF
///////////////////////////////////////////////////////////////////////////////////////////
default: // Menu node rendering (templates)
$oP->add_header('X-Frame-Options: deny');
ApplicationMenu::LoadAdditionalMenus();
$oMenuNode = ApplicationMenu::GetMenuNode(ApplicationMenu::GetMenuIndexById(ApplicationMenu::GetActiveNodeId()));
if (is_object($oMenuNode))

View File

@@ -31,6 +31,7 @@ ApplicationMenu::CheckMenuIdEnabled('UniversalSearchMenu');
$oAppContext = new ApplicationContext();
$oP = new iTopWebPage(Dict::S('UI:UniversalSearchTitle'));
$oP->add_header('X-Frame-Options: deny');
$oP->add_linked_script("../js/json.js");
$oP->add_linked_script("../js/forms-json-utils.js");
$oP->add_linked_script("../js/wizardhelper.js");

View File

@@ -93,6 +93,7 @@ $oAppContext = new ApplicationContext();
$oP = new iTopWebPage(Dict::S('UI:RunQuery:Title'));
$oP->SetBreadCrumbEntry('ui-tool-runquery', Dict::S('Menu:RunQueriesMenu'), Dict::S('Menu:RunQueriesMenu+'), '', utils::GetAbsoluteUrlAppRoot().'images/wrench.png');
$oP->add_header('X-Frame-Options: deny');
// Main program
$sExpression = utils::ReadParam('expression', '', false, 'raw_data');

View File

@@ -1119,6 +1119,7 @@ $operation = utils::ReadParam('operation', '');
$oPage = new iTopWebPage(Dict::S('UI:Schema:Title'));
$oPage->no_cache();
$oPage->add_header('X-Frame-Options: deny');
$oPage->SetBreadCrumbEntry('ui-tool-datamodel', Dict::S('Menu:DataModelMenu'), Dict::S('Menu:DataModelMenu+'), '',
utils::GetAbsoluteUrlAppRoot().'images/wrench.png');

View File

@@ -44,6 +44,7 @@ function ReportErrorAndExit($sErrorMessage)
else
{
$oP = new WebPage("iTop - Export");
$oP->add_header('X-Frame-Options: deny');
$oP->p('ERROR: '.$sErrorMessage);
$oP->output();
exit(-1);
@@ -63,6 +64,7 @@ function ReportErrorAndUsage($sErrorMessage)
else
{
$oP = new WebPage("iTop - Export");
$oP->add_header('X-Frame-Options: deny');
$oP->p('ERROR: '.$sErrorMessage);
Usage($oP);
$oP->output();
@@ -344,6 +346,7 @@ function InteractiveShell($sExpression, $sQueryId, $sFormat, $sFileName, $sMode)
if ($sMode == 'dialog')
{
$oP = new ajax_page('');
$oP->add_header('X-Frame-Options: deny');
$oP->add('<div id="interactive_export_dlg">');
$sExportBtnLabel = json_encode(Dict::S('UI:Button:Export'));
$sJSTitle = json_encode(htmlentities(utils::ReadParam('dialog_title', '', false, 'raw_data'), ENT_QUOTES, 'UTF-8'));
@@ -369,6 +372,7 @@ EOF
else
{
$oP = new iTopWebPage('iTop Export');
$oP->add_header('X-Frame-Options: deny');
$oP->SetBreadCrumbEntry('ui-tool-export', Dict::S('Menu:ExportMenu'), Dict::S('Menu:ExportMenu+'), '', utils::GetAbsoluteUrlAppRoot().'images/wrench.png');
}
@@ -729,6 +733,7 @@ try
if($oExporter instanceof HTMLBulkExport)
{
$oP = new NiceWebPage('iTop export');
$oP->add_header('X-Frame-Options: deny');
$oP->add_ready_script("$('table.listResults').tablesorter({widgets: ['MyZebra']});");
$oP->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-awesome/css/all.min.css');
$oP->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/font-awesome/css/v4-shims.min.css');
@@ -736,6 +741,7 @@ try
else
{
$oP = new WebPage('iTop export');
$oP->add_header('X-Frame-Options: deny');
$oP->add_style("table br { mso-data-placement:same-cell; }"); // Trick for Excel: keep line breaks inside the same cell !
}
$oP->add_style("body { overflow: auto; }");
@@ -743,6 +749,7 @@ try
else
{
$oP = new ajax_page('iTop export');
$oP->add_header('X-Frame-Options: deny');
$oP->SetContentType($oExporter->GetMimeType());
}
DoExport($oP, $oExporter, false);
@@ -752,6 +759,7 @@ try
catch (BulkExportMissingParameterException $e)
{
$oP = new ajax_page('iTop Export');
$oP->add_header('X-Frame-Options: deny');
$oP->add($e->getMessage());
Usage($oP);
$oP->output();
@@ -759,6 +767,7 @@ catch (BulkExportMissingParameterException $e)
catch (Exception $e)
{
$oP = new WebPage('iTop Export');
$oP->add_header('X-Frame-Options: deny');
$oP->add('Error: '.$e->getMessage());
IssueLog::Error($e->getMessage()."\n".$e->getTraceAsString());
$oP->output();