From: Philippe Antoine Date: Thu, 30 Jan 2025 12:42:19 +0000 (+0100) Subject: http: minor cleanups for lua X-Git-Tag: suricata-8.0.0-beta1~484 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44a363f2f96c1cdc424c63a63ea01e29cf12ffc0;p=thirdparty%2Fsuricata.git http: minor cleanups for lua In preparation of libhtp rust Mainly adding some const --- diff --git a/src/util-lua-http.c b/src/util-lua-http.c index d4d056ad03..6c3a512df9 100644 --- a/src/util-lua-http.c +++ b/src/util-lua-http.c @@ -154,13 +154,13 @@ static int HttpGetHeader(lua_State *luastate, int dir) if (name == NULL) return LuaCallbackError(luastate, "1st argument missing, empty or wrong type"); - const htp_headers_t *headers = htp_tx_request_headers(tx); - if (dir == 1) - headers = htp_tx_response_headers(tx); - if (headers == NULL) - return LuaCallbackError(luastate, "tx has no headers"); + const htp_header_t *h = NULL; + if (dir == 0) { + h = htp_tx_request_header(tx, name); + } else { + h = htp_tx_response_header(tx, name); + } - htp_header_t *h = (htp_header_t *)htp_table_get_c(headers, name); if (h == NULL || htp_header_value_len(h) == 0) return LuaCallbackError(luastate, "header not found"); @@ -226,11 +226,11 @@ static int HttpGetHeaders(lua_State *luastate, int dir) const htp_headers_t *table = htp_tx_request_headers(tx); if (dir == 1) table = htp_tx_response_headers(tx); - if (htp_tx_request_headers(tx) == NULL) + if (table == NULL) return LuaCallbackError(luastate, "no headers"); lua_newtable(luastate); - htp_header_t *h = NULL; + const htp_header_t *h = NULL; size_t i = 0; size_t no_of_headers = htp_headers_size(table); for (; i < no_of_headers; i++) {