Skip to content

Commit 0768148

Browse files
committed
Inline header_start in request helper struct
1 parent 8cd57c3 commit 0768148

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

src/lib/lwan-private.h

+20-20
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,31 @@
2424

2525
#include "lwan.h"
2626

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

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

34-
struct lwan_value accept_encoding; /* Accept-Encoding: */
35+
struct lwan_value accept_encoding; /* Accept-Encoding: */
3536

36-
struct lwan_value query_string; /* Stuff after ? and before # */
37+
struct lwan_value query_string; /* Stuff after ? and before # */
3738

38-
struct lwan_value body_data; /* Request body for POST and PUT */
39-
struct lwan_value content_type; /* Content-Type: for POST and PUT */
40-
struct lwan_value content_length; /* Content-Length: */
39+
struct lwan_value body_data; /* Request body for POST and PUT */
40+
struct lwan_value content_type; /* Content-Type: for POST and PUT */
41+
struct lwan_value content_length; /* Content-Length: */
4142

42-
struct lwan_value connection; /* Connection: */
43+
struct lwan_value connection; /* Connection: */
4344

44-
struct lwan_value host; /* Host: */
45+
struct lwan_value host; /* Host: */
4546

4647
struct lwan_key_value_array cookies, query_params, post_params;
4748

49+
char *header_start[N_HEADER_START]; /* Headers: n: start, n+1: end */
50+
size_t n_header_start; /* len(header_start) */
51+
4852
struct { /* If-Modified-Since: */
4953
struct lwan_value raw;
5054
time_t parsed;
@@ -55,17 +59,13 @@ struct lwan_request_parser_helper {
5559
off_t from, to;
5660
} range;
5761

58-
uint64_t request_id; /* Request ID for debugging purposes */
62+
uint64_t request_id; /* Request ID for debugging purposes */
5963

60-
time_t error_when_time; /* Time to abort request read */
61-
int error_when_n_packets; /* Max. number of packets */
62-
int urls_rewritten; /* Times URLs have been rewritten */
64+
time_t error_when_time; /* Time to abort request read */
65+
int error_when_n_packets; /* Max. number of packets */
66+
int urls_rewritten; /* Times URLs have been rewritten */
6367
};
6468

65-
#define DEFAULT_BUFFER_SIZE 4096
66-
#define DEFAULT_HEADERS_SIZE 2048
67-
68-
#define N_HEADER_START 64
6969

7070
#define LWAN_CONCAT(a_, b_) a_ ## b_
7171
#define LWAN_TMP_ID_DETAIL(n_) LWAN_CONCAT(lwan_tmp_id, n_)

src/lib/lwan-thread.c

-2
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ __attribute__((noreturn)) static int process_request_coro(struct coro *coro,
454454
struct lwan_strbuf strbuf = LWAN_STRBUF_STATIC_INIT;
455455
struct lwan_value buffer;
456456
char *next_request = NULL;
457-
char *header_start[N_HEADER_START];
458457
struct lwan_proxy proxy;
459458
size_t init_gen;
460459

@@ -506,7 +505,6 @@ __attribute__((noreturn)) static int process_request_coro(struct coro *coro,
506505
.buffer = &buffer,
507506
.next_request = next_request,
508507
.error_when_n_packets = error_when_n_packets,
509-
.header_start = header_start,
510508
};
511509
struct lwan_request request = {.conn = conn,
512510
.global_response_headers = &lwan->headers,

0 commit comments

Comments
 (0)