diff --git a/httpdbg/__init__.py b/httpdbg/__init__.py index b67e49e..1197b8a 100644 --- a/httpdbg/__init__.py +++ b/httpdbg/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.1.2" +__version__ = "2.1.3" __all__ = ["export_html", "httprecord", "HTTPRecords"] diff --git a/httpdbg/webapp/static/api.js b/httpdbg/webapp/static/api.js index 70db6b4..e20463d 100644 --- a/httpdbg/webapp/static/api.js +++ b/httpdbg/webapp/static/api.js @@ -84,37 +84,35 @@ async function get_all_requests() { const data = await load_all_requests(); - if (!data) { - return; - } + if (data) { + if (data.session.id != global.session) { + clean(); + global.session = data.session.id; + global.sessions[data.session.id] = data.session; + }; - if (data.session.id != global.session) { - clean(); - global.session = data.session.id; - global.sessions[data.session.id] = data.session; - }; - - // for the initiators and the groups, we can just save them without any verification - Object.assign(global.initiators, data.initiators); - Object.assign(global.groups, data.groups); - - // for the requests, we may have to update them - for (const [request_id, request] of Object.entries(data.requests)) { - if (!(request_id in global.requests)) { - // this is a new request - save_request(request_id, request, data.session.id); - } else { - if (global.requests[request_id].last_update < request.last_update) { - // this request has been updated (probably a "big" file) + // for the initiators and the groups, we can just save them without any verification + Object.assign(global.initiators, data.initiators); + Object.assign(global.groups, data.groups); + + // for the requests, we may have to update them + for (const [request_id, request] of Object.entries(data.requests)) { + if (!(request_id in global.requests)) { + // this is a new request save_request(request_id, request, data.session.id); - } + } else { + if (global.requests[request_id].last_update < request.last_update) { + // this request has been updated (probably a "big" file) + save_request(request_id, request, data.session.id); + } + }; }; - }; + } } async function load_request(request_id) { if (typeof global.static_requests !== "undefined") { - global.connected = false; + global.connected = false; return global.static_requests[request_id]; } @@ -126,46 +124,43 @@ async function load_request(request_id) { } catch (error) { global.connected = false; return null; - } + } } async function get_request(request_id) { - const data = await load_request(request_id); - if (!data) { - return; - } - - global.requests[request_id].filter = prepare_for_filter(global.requests[request_id].url); - - global.requests[request_id].request = data.request; - if (data.request.body && data.request.body.text) { - global.requests[request_id].filter += " " + prepare_for_filter( - parse_raw_text( - data.request.body.text, - data.request.body.content_type - ) || data.request.body.text - ); - } + if (data) { + global.requests[request_id].filter = prepare_for_filter(global.requests[request_id].url); + + global.requests[request_id].request = data.request; + if (data.request.body && data.request.body.text) { + global.requests[request_id].filter += " " + prepare_for_filter( + parse_raw_text( + data.request.body.text, + data.request.body.content_type + ) || data.request.body.text + ); + } - global.requests[request_id].response = data.response; - if (data.response.body && data.response.body.text) { - global.requests[request_id].filter += " " + prepare_for_filter( - parse_raw_text( - data.response.body.text, - data.response.body.content_type - ) || data.response.body.text - ); - } + global.requests[request_id].response = data.response; + if (data.response.body && data.response.body.text) { + global.requests[request_id].filter += " " + prepare_for_filter( + parse_raw_text( + data.response.body.text, + data.response.body.content_type + ) || data.response.body.text + ); + } - // the full stack is not present in request summary - global.requests[request_id].initiator_id = data.initiator_id; - global.requests[request_id].exception = data.exception; + // the full stack is not present in request summary + global.requests[request_id].initiator_id = data.initiator_id; + global.requests[request_id].exception = data.exception; - global.requests[request_id].to_refresh = true; + global.requests[request_id].to_refresh = true; - global.requests[request_id].loaded = true; + global.requests[request_id].loaded = true; + } } async function pol_new_data() { diff --git a/httpdbg/webapp/static/render.js b/httpdbg/webapp/static/render.js index 26cfad9..0450400 100644 --- a/httpdbg/webapp/static/render.js +++ b/httpdbg/webapp/static/render.js @@ -7,7 +7,7 @@ async function refresh_resquests() { var template_request = document.getElementById("template_request").innerHTML; var template_group = document.getElementById("template_group").innerHTML; - if (global.session != session_id) { + if (session_id != null && global.session !== session_id) { clean(); }; session_id = global.session;