Skip to content

Commit

Permalink
Inline header_start in request helper struct
Browse files Browse the repository at this point in the history
  • Loading branch information
lpereira committed Apr 14, 2024
1 parent 8cd57c3 commit 0768148
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
40 changes: 20 additions & 20 deletions src/lib/lwan-private.h
Expand Up @@ -24,27 +24,31 @@

#include "lwan.h"

struct lwan_request_parser_helper {
struct lwan_value *buffer; /* The whole request buffer */
char *next_request; /* For pipelined requests */
#define N_HEADER_START 64
#define DEFAULT_BUFFER_SIZE 4096
#define DEFAULT_HEADERS_SIZE 2048

char **header_start; /* Headers: n: start, n+1: end */
size_t n_header_start; /* len(header_start) */
struct lwan_request_parser_helper {
struct lwan_value *buffer; /* The whole request buffer */
char *next_request; /* For pipelined requests */

struct lwan_value accept_encoding; /* Accept-Encoding: */
struct lwan_value accept_encoding; /* Accept-Encoding: */

struct lwan_value query_string; /* Stuff after ? and before # */
struct lwan_value query_string; /* Stuff after ? and before # */

struct lwan_value body_data; /* Request body for POST and PUT */
struct lwan_value content_type; /* Content-Type: for POST and PUT */
struct lwan_value content_length; /* Content-Length: */
struct lwan_value body_data; /* Request body for POST and PUT */
struct lwan_value content_type; /* Content-Type: for POST and PUT */
struct lwan_value content_length; /* Content-Length: */

struct lwan_value connection; /* Connection: */
struct lwan_value connection; /* Connection: */

struct lwan_value host; /* Host: */
struct lwan_value host; /* Host: */

struct lwan_key_value_array cookies, query_params, post_params;

char *header_start[N_HEADER_START]; /* Headers: n: start, n+1: end */
size_t n_header_start; /* len(header_start) */

struct { /* If-Modified-Since: */
struct lwan_value raw;
time_t parsed;
Expand All @@ -55,17 +59,13 @@ struct lwan_request_parser_helper {
off_t from, to;
} range;

uint64_t request_id; /* Request ID for debugging purposes */
uint64_t request_id; /* Request ID for debugging purposes */

time_t error_when_time; /* Time to abort request read */
int error_when_n_packets; /* Max. number of packets */
int urls_rewritten; /* Times URLs have been rewritten */
time_t error_when_time; /* Time to abort request read */
int error_when_n_packets; /* Max. number of packets */
int urls_rewritten; /* Times URLs have been rewritten */
};

#define DEFAULT_BUFFER_SIZE 4096
#define DEFAULT_HEADERS_SIZE 2048

#define N_HEADER_START 64

#define LWAN_CONCAT(a_, b_) a_ ## b_
#define LWAN_TMP_ID_DETAIL(n_) LWAN_CONCAT(lwan_tmp_id, n_)
Expand Down
2 changes: 0 additions & 2 deletions src/lib/lwan-thread.c
Expand Up @@ -454,7 +454,6 @@ __attribute__((noreturn)) static int process_request_coro(struct coro *coro,
struct lwan_strbuf strbuf = LWAN_STRBUF_STATIC_INIT;
struct lwan_value buffer;
char *next_request = NULL;
char *header_start[N_HEADER_START];
struct lwan_proxy proxy;
size_t init_gen;

Expand Down Expand Up @@ -506,7 +505,6 @@ __attribute__((noreturn)) static int process_request_coro(struct coro *coro,
.buffer = &buffer,
.next_request = next_request,
.error_when_n_packets = error_when_n_packets,
.header_start = header_start,
};
struct lwan_request request = {.conn = conn,
.global_response_headers = &lwan->headers,
Expand Down

0 comments on commit 0768148

Please sign in to comment.