From 74e6771fd30209fca14797d5ddc9760541d2c770 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 2 Jul 2024 18:51:00 +0400 Subject: [PATCH] feat(schema): add method & code columns --- addon.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addon.py b/addon.py index ee7a238..259c595 100644 --- a/addon.py +++ b/addon.py @@ -16,7 +16,9 @@ with db as conn: conn.executescript(''' create table if not exists data ( id integer primary key, - url text not null + method text not null default "GET", + url text not null, + code integer default null ); ''') @@ -30,7 +32,11 @@ def response(flow: HTTPFlow) -> None: return uid: int = 0 with db as conn: - cur = conn.execute('insert into data (url) values (?) returning id', (url,)) + code = flow.response.status_code + cur = conn.execute( + 'insert into data (method, url, code) values (?, ?, ?) returning id', + (req.method, url, code if code != 200 else None), + ) uid = cur.fetchone()[0] path = os.path.join(storage, f'{uid}') if not os.path.exists(path):