From 31fe52b32d35201af5fb7fe0da5bb39c976b56dc Mon Sep 17 00:00:00 2001 From: cle-b Date: Sun, 2 Nov 2025 13:52:48 +0100 Subject: [PATCH 1/2] fix an unexpected clear of the requests list --- httpdbg/__init__.py | 2 +- httpdbg/webapp/static/api.js | 106 +++++++++++++++----------------- httpdbg/webapp/static/render.js | 2 +- 3 files changed, 53 insertions(+), 57 deletions(-) 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..8dac3d5 100644 --- a/httpdbg/webapp/static/api.js +++ b/httpdbg/webapp/static/api.js @@ -13,6 +13,7 @@ const global = { function save_request(request_id, request, session_id) { const initiator = global.initiators[request.initiator_id] ?? null; + console.log("initiator " + initiator); if (initiator !== null) { // the initiator may be missing if the clean list is executed in parrallel request.loaded = false; request.to_refresh = true; @@ -84,37 +85,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 +125,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; From a3ae8b68c51f9537fae31ecb9864b99ca34c8159 Mon Sep 17 00:00:00 2001 From: cle-b Date: Sun, 2 Nov 2025 14:13:18 +0100 Subject: [PATCH 2/2] remove log --- httpdbg/webapp/static/api.js | 1 - 1 file changed, 1 deletion(-) diff --git a/httpdbg/webapp/static/api.js b/httpdbg/webapp/static/api.js index 8dac3d5..e20463d 100644 --- a/httpdbg/webapp/static/api.js +++ b/httpdbg/webapp/static/api.js @@ -13,7 +13,6 @@ const global = { function save_request(request_id, request, session_id) { const initiator = global.initiators[request.initiator_id] ?? null; - console.log("initiator " + initiator); if (initiator !== null) { // the initiator may be missing if the clean list is executed in parrallel request.loaded = false; request.to_refresh = true;