Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/conns.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void conn_struct_init(struct conn_s *connptr) {
connptr->error_number = -1;
connptr->client_fd = -1;
connptr->server_fd = -1;
connptr->is_head_method = 0;
/* There is _no_ content length initially */
connptr->content_length.server = connptr->content_length.client = -1;
}
Expand Down
1 change: 1 addition & 0 deletions src/conns.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct conn_s {
/* Booleans */
unsigned int connect_method;
unsigned int show_stats;
unsigned int is_head_method;

/*
* This structure stores key -> value mappings for substitution
Expand Down
3 changes: 3 additions & 0 deletions src/reqs.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ static struct request_s *process_request (struct conn_s *connptr,
ret = sscanf (connptr->request_line, "%[^ ] %[^ ] %[^ ]",
request->method, url, request->protocol);

/* Set flag if this is a HEAD request for stats optimization */
connptr->is_head_method = (strcasecmp (request->method, "HEAD") == 0);

if (ret == 2 && !strcasecmp (request->method, "GET")) {
request->protocol[0] = 0;

Expand Down
6 changes: 6 additions & 0 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ showstats (struct conn_s *connptr)
char opens[16], reqs[16], badconns[16], denied[16], refused[16];
FILE *statfile;

/* For HEAD requests, send headers only and return immediately */
if (connptr->is_head_method) {
send_http_headers (connptr, 200, "Statistic requested", "");
return 0;
}

snprintf (opens, sizeof (opens), "%lu", stats->num_open);
snprintf (reqs, sizeof (reqs), "%lu", stats->num_reqs);
snprintf (badconns, sizeof (badconns), "%lu", stats->num_badcons);
Expand Down