1e18a033bSKonstantin Ananyev
2e18a033bSKonstantin Ananyev/*
3e18a033bSKonstantin Ananyev * Copyright (C) Igor Sysoev
4e18a033bSKonstantin Ananyev * Copyright (C) Nginx, Inc.
5e18a033bSKonstantin Ananyev */
6e18a033bSKonstantin Ananyev
7e18a033bSKonstantin Ananyev
8e18a033bSKonstantin Ananyev#ifndef _NGX_HTTP_H_INCLUDED_
9e18a033bSKonstantin Ananyev#define _NGX_HTTP_H_INCLUDED_
10e18a033bSKonstantin Ananyev
11e18a033bSKonstantin Ananyev
12e18a033bSKonstantin Ananyev#include <ngx_config.h>
13e18a033bSKonstantin Ananyev#include <ngx_core.h>
14e18a033bSKonstantin Ananyev
15e18a033bSKonstantin Ananyev
16e18a033bSKonstantin Ananyevtypedef struct ngx_http_request_s     ngx_http_request_t;
17e18a033bSKonstantin Ananyevtypedef struct ngx_http_upstream_s    ngx_http_upstream_t;
18e18a033bSKonstantin Ananyevtypedef struct ngx_http_cache_s       ngx_http_cache_t;
19e18a033bSKonstantin Ananyevtypedef struct ngx_http_file_cache_s  ngx_http_file_cache_t;
20e18a033bSKonstantin Ananyevtypedef struct ngx_http_log_ctx_s     ngx_http_log_ctx_t;
21e18a033bSKonstantin Ananyevtypedef struct ngx_http_chunked_s     ngx_http_chunked_t;
22e18a033bSKonstantin Ananyevtypedef struct ngx_http_v2_stream_s   ngx_http_v2_stream_t;
23e18a033bSKonstantin Ananyev
24e18a033bSKonstantin Ananyevtypedef ngx_int_t (*ngx_http_header_handler_pt)(ngx_http_request_t *r,
25e18a033bSKonstantin Ananyev    ngx_table_elt_t *h, ngx_uint_t offset);
26e18a033bSKonstantin Ananyevtypedef u_char *(*ngx_http_log_handler_pt)(ngx_http_request_t *r,
27e18a033bSKonstantin Ananyev    ngx_http_request_t *sr, u_char *buf, size_t len);
28e18a033bSKonstantin Ananyev
29e18a033bSKonstantin Ananyev
30e18a033bSKonstantin Ananyev#include <ngx_http_variables.h>
31e18a033bSKonstantin Ananyev#include <ngx_http_config.h>
32e18a033bSKonstantin Ananyev#include <ngx_http_request.h>
33e18a033bSKonstantin Ananyev#include <ngx_http_script.h>
34e18a033bSKonstantin Ananyev#include <ngx_http_upstream.h>
35e18a033bSKonstantin Ananyev#include <ngx_http_upstream_round_robin.h>
36e18a033bSKonstantin Ananyev#include <ngx_http_core_module.h>
37e18a033bSKonstantin Ananyev
38e18a033bSKonstantin Ananyev#if (NGX_HTTP_V2)
39e18a033bSKonstantin Ananyev#include <ngx_http_v2.h>
40e18a033bSKonstantin Ananyev#endif
41e18a033bSKonstantin Ananyev#if (NGX_HTTP_CACHE)
42e18a033bSKonstantin Ananyev#include <ngx_http_cache.h>
43e18a033bSKonstantin Ananyev#endif
44e18a033bSKonstantin Ananyev#if (NGX_HTTP_SSI)
45e18a033bSKonstantin Ananyev#include <ngx_http_ssi_filter_module.h>
46e18a033bSKonstantin Ananyev#endif
47e18a033bSKonstantin Ananyev#if (NGX_HTTP_SSL)
48e18a033bSKonstantin Ananyev#include <ngx_http_ssl_module.h>
49e18a033bSKonstantin Ananyev#endif
50e18a033bSKonstantin Ananyev
51e18a033bSKonstantin Ananyev
52e18a033bSKonstantin Ananyevstruct ngx_http_log_ctx_s {
53e18a033bSKonstantin Ananyev    ngx_connection_t    *connection;
54e18a033bSKonstantin Ananyev    ngx_http_request_t  *request;
55e18a033bSKonstantin Ananyev    ngx_http_request_t  *current_request;
56e18a033bSKonstantin Ananyev};
57e18a033bSKonstantin Ananyev
58e18a033bSKonstantin Ananyev
59e18a033bSKonstantin Ananyevstruct ngx_http_chunked_s {
60e18a033bSKonstantin Ananyev    ngx_uint_t           state;
61e18a033bSKonstantin Ananyev    off_t                size;
62e18a033bSKonstantin Ananyev    off_t                length;
63e18a033bSKonstantin Ananyev};
64e18a033bSKonstantin Ananyev
65e18a033bSKonstantin Ananyev
66e18a033bSKonstantin Ananyevtypedef struct {
67e18a033bSKonstantin Ananyev    ngx_uint_t           http_version;
68e18a033bSKonstantin Ananyev    ngx_uint_t           code;
69e18a033bSKonstantin Ananyev    ngx_uint_t           count;
70e18a033bSKonstantin Ananyev    u_char              *start;
71e18a033bSKonstantin Ananyev    u_char              *end;
72e18a033bSKonstantin Ananyev} ngx_http_status_t;
73e18a033bSKonstantin Ananyev
74e18a033bSKonstantin Ananyev
75e18a033bSKonstantin Ananyev#define ngx_http_get_module_ctx(r, module)  (r)->ctx[module.ctx_index]
76e18a033bSKonstantin Ananyev#define ngx_http_set_ctx(r, c, module)      r->ctx[module.ctx_index] = c;
77e18a033bSKonstantin Ananyev
78e18a033bSKonstantin Ananyev
79e18a033bSKonstantin Ananyevngx_int_t ngx_http_add_location(ngx_conf_t *cf, ngx_queue_t **locations,
80e18a033bSKonstantin Ananyev    ngx_http_core_loc_conf_t *clcf);
81e18a033bSKonstantin Ananyevngx_int_t ngx_http_add_listen(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
82e18a033bSKonstantin Ananyev    ngx_http_listen_opt_t *lsopt);
83e18a033bSKonstantin Ananyev
84e18a033bSKonstantin Ananyev
85e18a033bSKonstantin Ananyevvoid ngx_http_init_connection(ngx_connection_t *c);
86e18a033bSKonstantin Ananyevvoid ngx_http_close_connection(ngx_connection_t *c);
87e18a033bSKonstantin Ananyev
88e18a033bSKonstantin Ananyev#if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME)
89e18a033bSKonstantin Ananyevint ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg);
90e18a033bSKonstantin Ananyev#endif
91e18a033bSKonstantin Ananyev
92e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b);
93e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_uri(ngx_http_request_t *r);
94e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r,
95e18a033bSKonstantin Ananyev    ngx_uint_t merge_slashes);
96e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_status_line(ngx_http_request_t *r, ngx_buf_t *b,
97e18a033bSKonstantin Ananyev    ngx_http_status_t *status);
98e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_unsafe_uri(ngx_http_request_t *r, ngx_str_t *uri,
99e18a033bSKonstantin Ananyev    ngx_str_t *args, ngx_uint_t *flags);
100e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b,
101e18a033bSKonstantin Ananyev    ngx_uint_t allow_underscores);
102e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_multi_header_lines(ngx_array_t *headers,
103e18a033bSKonstantin Ananyev    ngx_str_t *name, ngx_str_t *value);
104e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_set_cookie_lines(ngx_array_t *headers,
105e18a033bSKonstantin Ananyev    ngx_str_t *name, ngx_str_t *value);
106e18a033bSKonstantin Ananyevngx_int_t ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len,
107e18a033bSKonstantin Ananyev    ngx_str_t *value);
108e18a033bSKonstantin Ananyevvoid ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri,
109e18a033bSKonstantin Ananyev    ngx_str_t *args);
110e18a033bSKonstantin Ananyevngx_int_t ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b,
111e18a033bSKonstantin Ananyev    ngx_http_chunked_t *ctx);
112e18a033bSKonstantin Ananyev
113e18a033bSKonstantin Ananyev
114e18a033bSKonstantin Ananyevngx_http_request_t *ngx_http_create_request(ngx_connection_t *c);
115e18a033bSKonstantin Ananyevngx_int_t ngx_http_process_request_uri(ngx_http_request_t *r);
116e18a033bSKonstantin Ananyevngx_int_t ngx_http_process_request_header(ngx_http_request_t *r);
117e18a033bSKonstantin Ananyevvoid ngx_http_process_request(ngx_http_request_t *r);
118e18a033bSKonstantin Ananyevvoid ngx_http_update_location_config(ngx_http_request_t *r);
119e18a033bSKonstantin Ananyevvoid ngx_http_handler(ngx_http_request_t *r);
120e18a033bSKonstantin Ananyevvoid ngx_http_run_posted_requests(ngx_connection_t *c);
121e18a033bSKonstantin Ananyevngx_int_t ngx_http_post_request(ngx_http_request_t *r,
122e18a033bSKonstantin Ananyev    ngx_http_posted_request_t *pr);
123e18a033bSKonstantin Ananyevvoid ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc);
124e18a033bSKonstantin Ananyevvoid ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc);
125e18a033bSKonstantin Ananyev
126e18a033bSKonstantin Ananyevvoid ngx_http_empty_handler(ngx_event_t *wev);
127e18a033bSKonstantin Ananyevvoid ngx_http_request_empty_handler(ngx_http_request_t *r);
128e18a033bSKonstantin Ananyev
129e18a033bSKonstantin Ananyev
130e18a033bSKonstantin Ananyev#define NGX_HTTP_LAST   1
131e18a033bSKonstantin Ananyev#define NGX_HTTP_FLUSH  2
132e18a033bSKonstantin Ananyev
133e18a033bSKonstantin Ananyevngx_int_t ngx_http_send_special(ngx_http_request_t *r, ngx_uint_t flags);
134e18a033bSKonstantin Ananyev
135e18a033bSKonstantin Ananyev
136e18a033bSKonstantin Ananyevngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
137e18a033bSKonstantin Ananyev    ngx_http_client_body_handler_pt post_handler);
138e18a033bSKonstantin Ananyevngx_int_t ngx_http_read_unbuffered_request_body(ngx_http_request_t *r);
139e18a033bSKonstantin Ananyev
140e18a033bSKonstantin Ananyevngx_int_t ngx_http_send_header(ngx_http_request_t *r);
141e18a033bSKonstantin Ananyevngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
142e18a033bSKonstantin Ananyev    ngx_int_t error);
143e18a033bSKonstantin Ananyevngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
144e18a033bSKonstantin Ananyev    ngx_module_t *m, ngx_int_t error);
145e18a033bSKonstantin Ananyevvoid ngx_http_clean_header(ngx_http_request_t *r);
146e18a033bSKonstantin Ananyev
147e18a033bSKonstantin Ananyev
148e18a033bSKonstantin Ananyevngx_int_t ngx_http_discard_request_body(ngx_http_request_t *r);
149e18a033bSKonstantin Ananyevvoid ngx_http_discarded_request_body_handler(ngx_http_request_t *r);
150e18a033bSKonstantin Ananyevvoid ngx_http_block_reading(ngx_http_request_t *r);
151e18a033bSKonstantin Ananyevvoid ngx_http_test_reading(ngx_http_request_t *r);
152e18a033bSKonstantin Ananyev
153e18a033bSKonstantin Ananyev
154e18a033bSKonstantin Ananyevchar *ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
155e18a033bSKonstantin Ananyevchar *ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t **keys,
156e18a033bSKonstantin Ananyev    ngx_hash_t *types_hash, ngx_array_t **prev_keys,
157e18a033bSKonstantin Ananyev    ngx_hash_t *prev_types_hash, ngx_str_t *default_types);
158e18a033bSKonstantin Ananyevngx_int_t ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types,
159e18a033bSKonstantin Ananyev    ngx_str_t *default_type);
160e18a033bSKonstantin Ananyev
161e18a033bSKonstantin Ananyev#if (NGX_HTTP_DEGRADATION)
162e18a033bSKonstantin Ananyevngx_uint_t  ngx_http_degraded(ngx_http_request_t *);
163e18a033bSKonstantin Ananyev#endif
164e18a033bSKonstantin Ananyev
165e18a033bSKonstantin Ananyev
166e18a033bSKonstantin Ananyevextern ngx_module_t  ngx_http_module;
167e18a033bSKonstantin Ananyev
168e18a033bSKonstantin Ananyevextern ngx_str_t  ngx_http_html_default_types[];
169e18a033bSKonstantin Ananyev
170e18a033bSKonstantin Ananyev
171e18a033bSKonstantin Ananyevextern ngx_http_output_header_filter_pt  ngx_http_top_header_filter;
172e18a033bSKonstantin Ananyevextern ngx_http_output_body_filter_pt    ngx_http_top_body_filter;
173e18a033bSKonstantin Ananyevextern ngx_http_request_body_filter_pt   ngx_http_top_request_body_filter;
174e18a033bSKonstantin Ananyev
175e18a033bSKonstantin Ananyev
176e18a033bSKonstantin Ananyev#endif /* _NGX_HTTP_H_INCLUDED_ */
177