Skip to content

Commit

Permalink
eve/http: use numeric status code by default
Browse files Browse the repository at this point in the history
To avoid costly string operations.
  • Loading branch information
victorjulien committed Jan 8, 2024
1 parent f5565f4 commit 9a14d7a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/output-json-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,13 @@ static void EveHttpLogJSONExtended(JsonBuilder *js, htp_tx_t *tx)
js, "protocol", bstr_ptr(tx->request_protocol), bstr_len(tx->request_protocol));
}

/* response status */
if (tx->response_status != NULL) {
/* response status: from libhtp:
* "Response status code, available only if we were able to parse it, HTP_STATUS_INVALID
* otherwise. HTP_STATUS_UNKNOWN until parsing is attempted" .*/
const int resp = tx->response_status_number;
if (resp > 0) {
jb_set_uint(js, "status", (uint32_t)resp);
} else if (tx->response_status != NULL) {
const size_t status_size = bstr_len(tx->response_status) * 2 + 1;
char status_string[status_size];
BytesToStringBuffer(bstr_ptr(tx->response_status), bstr_len(tx->response_status),
Expand Down

0 comments on commit 9a14d7a

Please sign in to comment.