Skip to content

Commit

Permalink
status should be a number
Browse files Browse the repository at this point in the history
  • Loading branch information
gquintard committed Mar 22, 2024
1 parent f734209 commit 3326bd0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ add_compile_options(-Wall -Wextra -Wpedantic)

# what's in our executable
add_executable(varnishlog-json main.c varnishlog-json_options.h)
# link against the varnish libraries
target_link_libraries(varnishlog-json PkgConfig::VARNISH cjson)
# link against various libraries
target_link_libraries(varnishlog-json PkgConfig::VARNISH cjson m)
# need this to find varnish-varnishlog-json_options.h
target_include_directories(varnishlog-json PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS varnishlog-json)
Expand Down
16 changes: 13 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <ctype.h>
#include <math.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -252,9 +253,6 @@ static int process_group(struct VSL_data *vsl,
save_data(RespReason, !resp_done, resp, "reason");
save_data(BerespReason, !resp_done, resp, "reason");

save_data(RespStatus, !resp_done, resp, "status");
save_data(BerespStatus, !resp_done, resp, "status");

save_data(RespProtocol, !resp_done, resp, "proto");
save_data(BerespProtocol, !resp_done, resp, "proto");

Expand All @@ -264,6 +262,18 @@ static int process_group(struct VSL_data *vsl,

save_data(Storage, true, transaction, "storage");

case SLT_RespStatus:
/* passthrough */
case SLT_BerespStatus: {
double status = strtod(data, NULL);
// Varnish won't accept those, we shouldn't either
assert(status > 0);
assert(status < 1000);
assert(status == round(status));
if (!req_done)
cJSON_AddNumberToObject(req, data, status);
break;
}
case SLT_ReqHeader:
/* passthrough */
case SLT_BereqHeader:
Expand Down

0 comments on commit 3326bd0

Please sign in to comment.