From 668cb6418f90866c3a8f6d8f3abc3d1f615185b4 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sun, 5 Jan 2020 22:08:41 -0500 Subject: [PATCH] [core] move request_st,request_config to request.h --- src/base.h | 91 +------------------------------------------------ src/request.h | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 90 deletions(-) diff --git a/src/base.h b/src/base.h index 7db665ab..3b77fd90 100644 --- a/src/base.h +++ b/src/base.h @@ -10,6 +10,7 @@ #include "array.h" #include "chunk.h" #include "http_kv.h" +#include "request.h" #include "sock_addr.h" struct fdevents; /* declaration */ @@ -20,33 +21,6 @@ struct cond_match_t; /* declaration */ #define DIRECT 0 /* con->mode */ -typedef struct request_st { - /** HEADER */ - /* the request-line */ - buffer *request; - buffer *uri; - - buffer *orig_uri; - - http_method_t http_method; - http_version_t http_version; - - /* strings to the header */ - buffer *http_host; /* not alloced */ - - unsigned int htags; /* bitfield of flagged headers present in request */ - array headers; - - /* CONTENT */ - off_t content_length; /* returned by strtoll() */ - off_t te_chunked; - - int keep_alive; /* only request.c can enable it, all other just disable */ - - /* internal */ - buffer *pathinfo; -} request; - typedef struct { off_t content_length; unsigned int htags; /* bitfield of flagged headers present in response */ @@ -76,69 +50,6 @@ typedef struct { buffer *etag; } physical; -typedef struct { - const array *mimetypes; - - /* virtual-servers */ - const buffer *document_root; - const buffer *server_name; - const buffer *server_tag; - log_error_st *errh; - - uint32_t max_request_field_size; - unsigned short max_keep_alive_requests; - unsigned short max_keep_alive_idle; - unsigned short max_read_idle; - unsigned short max_write_idle; - unsigned short stream_request_body; - unsigned short stream_response_body; - unsigned char high_precision_timestamps; - unsigned char allow_http11; - unsigned char follow_symlink; - unsigned char etag_flags; - unsigned char force_lowercase_filenames; /* if the FS is case-insensitive, force all files to lower-case */ - unsigned char use_xattr; - unsigned char range_requests; - unsigned char error_intercept; - - /* debug */ - - unsigned char log_file_not_found; - unsigned char log_request_header; - unsigned char log_request_handling; - unsigned char log_response_header; - unsigned char log_condition_handling; - unsigned char log_timeouts; - unsigned char log_state_handling; - unsigned char log_request_header_on_error; - - unsigned int http_parseopts; - unsigned int max_request_size; - - unsigned int bytes_per_second; /* connection bytes/sec limit */ - unsigned int global_bytes_per_second;/*total bytes/sec limit for scope*/ - - /* server-wide traffic-shaper - * - * each context has the counter which is inited once - * a second by the global_bytes_per_second config-var - * - * as soon as global_bytes_per_second gets below 0 - * the connected conns are "offline" a little bit - * - * the problem: - * we somehow have to loose our "we are writable" signal - * on the way. - * - */ - off_t *global_bytes_per_second_cnt_ptr; /* */ - - const buffer *error_handler; - const buffer *error_handler_404; - const buffer *errorfile_prefix; - log_error_st *serrh; /* script errh */ -} request_config; - /* the order of the items should be the same as they are processed * read before write as we use this later */ typedef enum { diff --git a/src/request.h b/src/request.h index e131342e..dd410211 100644 --- a/src/request.h +++ b/src/request.h @@ -4,6 +4,100 @@ #include "base_decls.h" #include "buffer.h" +#include "array.h" +#include "http_kv.h" + +struct log_error_st; /* declaration */ + +typedef struct { + const array *mimetypes; + + /* virtual-servers */ + const buffer *document_root; + const buffer *server_name; + const buffer *server_tag; + struct log_error_st *errh; + + uint32_t max_request_field_size; + unsigned short max_keep_alive_requests; + unsigned short max_keep_alive_idle; + unsigned short max_read_idle; + unsigned short max_write_idle; + unsigned short stream_request_body; + unsigned short stream_response_body; + unsigned char high_precision_timestamps; + unsigned char allow_http11; + unsigned char follow_symlink; + unsigned char etag_flags; + unsigned char force_lowercase_filenames; /*(case-insensitive file systems)*/ + unsigned char use_xattr; + unsigned char range_requests; + unsigned char error_intercept; + + /* debug */ + + unsigned char log_file_not_found; + unsigned char log_request_header; + unsigned char log_request_handling; + unsigned char log_response_header; + unsigned char log_condition_handling; + unsigned char log_timeouts; + unsigned char log_state_handling; + unsigned char log_request_header_on_error; + + unsigned int http_parseopts; + unsigned int max_request_size; + + unsigned int bytes_per_second; /* connection bytes/sec limit */ + unsigned int global_bytes_per_second;/*total bytes/sec limit for scope*/ + + /* server-wide traffic-shaper + * + * each context has the counter which is inited once + * a second by the global_bytes_per_second config-var + * + * as soon as global_bytes_per_second gets below 0 + * the connected conns are "offline" a little bit + * + * the problem: + * we somehow have to lose our "we are writable" signal on the way. + * + */ + off_t *global_bytes_per_second_cnt_ptr; /* */ + + const buffer *error_handler; + const buffer *error_handler_404; + const buffer *errorfile_prefix; + struct log_error_st *serrh; /* script errh */ +} request_config; + +typedef struct request_st { + /** HEADER */ + /* the request-line */ + buffer *request; + buffer *uri; + + buffer *orig_uri; + + http_method_t http_method; + http_version_t http_version; + + /* strings to the header */ + buffer *http_host; /* not alloced */ + + unsigned int htags; /* bitfield of flagged headers present in request */ + array headers; + + /* CONTENT */ + off_t content_length; /* returned by strtoll() */ + off_t te_chunked; + + int keep_alive; /* only request.c can enable it, all other just disable */ + + /* internal */ + buffer *pathinfo; +} request; + int http_request_parse(connection *con, char *hdrs, const unsigned short *hloffsets, int scheme_port); int http_request_host_normalize(buffer *b, int scheme_port);