diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index 446717b1b7f..df9cd99b7d7 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -82,16 +82,15 @@ var LivechatButton = Widget.extend({ }, load_qweb_template: function(){ - return $.when( - $.get('/mail/static/src/xml/chat_window.xml'), - $.get('/mail/static/src/xml/thread.xml'), - $.get('/im_livechat/static/src/xml/im_livechat.xml') - ).then(function (chat_window, mail_thread, livechat) { - // results are triplets of [dom: XMLDocument, status: String, xhr: jqXHR] - QWeb.add_template(chat_window[0]); - QWeb.add_template(mail_thread[0]); - QWeb.add_template(livechat[0]); + var xml_files = ['/mail/static/src/xml/chat_window.xml', + '/mail/static/src/xml/thread.xml', + '/im_livechat/static/src/xml/im_livechat.xml']; + var defs = _.map(xml_files, function (tmpl) { + return session.rpc('/web/proxy/load', {path: tmpl}).then(function (xml) { + QWeb.add_template(xml); + }); }); + return $.when.apply($, defs); }, open_chat: _.debounce(function () { diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 3e6b19adf11..496f234f7e0 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -586,6 +586,22 @@ class WebClient(http.Controller): class Proxy(http.Controller): + @http.route('/web/proxy/load', type='json', auth="none") + def load(self, path): + """ Proxies an HTTP request through a JSON request. + + It is strongly recommended to not request binary files through this, + as the result will be a binary data blob as well. + + :param path: actual request path + :return: file content + """ + from werkzeug.test import Client + from werkzeug.wrappers import BaseResponse + + base_url = request.httprequest.base_url + return Client(request.httprequest.app, BaseResponse).get(path, base_url=base_url).data + @http.route('/web/proxy/post/', type='http', auth='user', methods=['GET']) def post(self, path): """Effectively execute a POST request that was hooked through user login"""