('Content-Disposition', 'attachment; filename="%s.%s"' % (action['report_name'], report_struct['format']))
这样的http header的定义。这是要直接下载。修改先:
header_list = [
('Content-Type', report_mimetype),
('Content-Length', len(report))]
if report_struct['format'] not in ['html']:
header_list.append(('Content-Disposition', 'attachment; filename="%s.%s"' % (action['report_name'], report_struct['format'])))
return req.make_response(report,
headers=header_list,
cookies={'fileToken': int(token)})
self.session.get_file({
url: '/web/report',
data: {action: JSON.stringify(action)},
complete: $.unblockUI,
success: function(){
if (!self.dialog && on_closed) {
on_closed();
}
self.dialog_stop();
},
error: session.webclient.crashmanager.on_rpc_error
})
post_data = {
url: '/web/report',
data: {action: JSON.stringify(action)},
complete: $.unblockUI,
success: function(){
if (!self.dialog && on_closed) {
on_closed();
}
self.dialog_stop();
},
error: session.webclient.crashmanager.on_rpc_error
};
if(action.report_type == 'mako2html'){
self.session.open_report_page(post_data)
}else{
self.session.get_file(post_data)
}
/**
*Open an html report.
*未处理error
**/
open_report_page: function(options) {
var token = new Date().getTime();
params = options.data;
params['session_id'] = this.session_id;
params['token'] = token;
$.post(options.url, params, function(data){
report_window=window.open('','','width=100,height=100');
report_window.document.write(data);
report_window.focus();
options.complete();
if (options.success) { options.success(); }
});
},