Skip to content

Commit

Permalink
fix: correct status code separator logic in JSON display
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Mar 5, 2025
1 parent b23df54 commit 9380978
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ngx_http_vhost_traffic_status_display_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ ngx_http_vhost_traffic_status_display_set_server_node(
buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER_STATUS_CODE_START);

ngx_uint_t *status_codes = (ngx_uint_t *) ctx->measure_status_codes->elts;
ngx_uint_t inserted = 0;
for (ngx_uint_t i = 0; i < ctx->measure_status_codes->nelts; i++) {
if (vtsn->stat_status_code_counter[i] == 0 && ctx->measure_all_status_codes) {
continue;
}
status_code = &status_codes[i];
if (i > 0) {
if (inserted > 0) {
buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER_STATUS_SEPARATOR);
}
buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER_STATUS_CODE,
*status_code, vtsn->stat_status_code_counter[i]);
inserted++;
}

buf = ngx_sprintf(buf, NGX_HTTP_VHOST_TRAFFIC_STATUS_JSON_FMT_SERVER_STATUS_CODE_END);
Expand Down

0 comments on commit 9380978

Please sign in to comment.