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