~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Nginx/http/ngx_http_upstream.h

Version: ~ [ nginx-0.6.26 ] ~ [ nginx-0.5.35 ] ~ [ nginx-0.5.20 ] ~ [ nginx-0.5.19 ] ~

  1 
  2 /*
  3  * Copyright (C) Igor Sysoev
  4  */
  5 
  6 
  7 #ifndef _NGX_HTTP_UPSTREAM_H_INCLUDED_
  8 #define _NGX_HTTP_UPSTREAM_H_INCLUDED_
  9 
 10 
 11 #include <ngx_config.h>
 12 #include <ngx_core.h>
 13 #include <ngx_event.h>
 14 #include <ngx_event_connect.h>
 15 #include <ngx_event_pipe.h>
 16 #include <ngx_http.h>
 17 
 18 
 19 #define NGX_HTTP_UPSTREAM_FT_ERROR           0x00000002
 20 #define NGX_HTTP_UPSTREAM_FT_TIMEOUT         0x00000004
 21 #define NGX_HTTP_UPSTREAM_FT_INVALID_HEADER  0x00000008
 22 #define NGX_HTTP_UPSTREAM_FT_HTTP_500        0x00000010
 23 #define NGX_HTTP_UPSTREAM_FT_HTTP_503        0x00000020
 24 #define NGX_HTTP_UPSTREAM_FT_HTTP_404        0x00000040
 25 #define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK       0x00000080
 26 #define NGX_HTTP_UPSTREAM_FT_MAX_WAITING     0x00000100
 27 #define NGX_HTTP_UPSTREAM_FT_NOLIVE          0x40000000
 28 #define NGX_HTTP_UPSTREAM_FT_OFF             0x80000000
 29 
 30 
 31 #define NGX_HTTP_UPSTREAM_INVALID_HEADER     40
 32 
 33 
 34 typedef struct {
 35     ngx_msec_t                      bl_time;
 36     ngx_uint_t                      bl_state;
 37 
 38     ngx_uint_t                      status;
 39     time_t                          response_sec;
 40     ngx_uint_t                      response_msec;
 41 
 42     ngx_str_t                      *peer;
 43 } ngx_http_upstream_state_t;
 44 
 45 
 46 typedef struct {
 47     ngx_hash_t                      headers_in_hash;
 48     ngx_array_t                     upstreams;
 49                                              /* ngx_http_upstream_srv_conf_t */
 50 } ngx_http_upstream_main_conf_t;
 51 
 52 typedef struct ngx_http_upstream_srv_conf_s  ngx_http_upstream_srv_conf_t;
 53 
 54 typedef ngx_int_t (*ngx_http_upstream_init_pt)(ngx_conf_t *cf,
 55     ngx_http_upstream_srv_conf_t *us);
 56 typedef ngx_int_t (*ngx_http_upstream_init_peer_pt)(ngx_http_request_t *r,
 57     ngx_http_upstream_srv_conf_t *us);
 58 
 59 
 60 typedef struct {
 61     ngx_http_upstream_init_pt       init_upstream;
 62     ngx_http_upstream_init_peer_pt  init;
 63     void                           *data;
 64 } ngx_http_upstream_peer_t;
 65 
 66 
 67 typedef struct {
 68     ngx_peer_addr_t                *addrs;
 69     ngx_uint_t                      naddrs;
 70     ngx_uint_t                      weight;
 71     ngx_uint_t                      max_fails;
 72     time_t                          fail_timeout;
 73 
 74     unsigned                        down:1;
 75     unsigned                        backup:1;
 76 } ngx_http_upstream_server_t;
 77 
 78 
 79 #define NGX_HTTP_UPSTREAM_CREATE        0x0001
 80 #define NGX_HTTP_UPSTREAM_WEIGHT        0x0002
 81 #define NGX_HTTP_UPSTREAM_MAX_FAILS     0x0004
 82 #define NGX_HTTP_UPSTREAM_FAIL_TIMEOUT  0x0008
 83 #define NGX_HTTP_UPSTREAM_DOWN          0x0010
 84 #define NGX_HTTP_UPSTREAM_BACKUP        0x0020
 85 
 86 
 87 struct ngx_http_upstream_srv_conf_s {
 88     ngx_http_upstream_peer_t        peer;
 89     void                          **srv_conf;
 90 
 91     ngx_array_t                    *servers;   /* ngx_http_upstream_server_t */
 92 
 93     ngx_uint_t                      flags;
 94     ngx_str_t                       host;
 95     u_char                         *file_name;
 96     ngx_uint_t                      line;
 97     in_port_t                       port;
 98     in_port_t                       default_port;
 99 };
100 
101 
102 typedef struct {
103     ngx_http_upstream_srv_conf_t   *upstream;
104 
105     ngx_msec_t                      connect_timeout;
106     ngx_msec_t                      send_timeout;
107     ngx_msec_t                      read_timeout;
108     ngx_msec_t                      timeout;
109 
110     size_t                          send_lowat;
111     size_t                          buffer_size;
112 
113     size_t                          busy_buffers_size;
114     size_t                          max_temp_file_size;
115     size_t                          temp_file_write_size;
116 
117     size_t                          busy_buffers_size_conf;
118     size_t                          max_temp_file_size_conf;
119     size_t                          temp_file_write_size_conf;
120 
121     ngx_uint_t                      next_upstream;
122     ngx_uint_t                      store_access;
123 
124     ngx_bufs_t                      bufs;
125 
126     ngx_flag_t                      buffering;
127     ngx_flag_t                      pass_request_headers;
128     ngx_flag_t                      pass_request_body;
129 
130     ngx_flag_t                      ignore_client_abort;
131     ngx_flag_t                      intercept_errors;
132     ngx_flag_t                      cyclic_temp_file;
133 
134     ngx_path_t                     *temp_path;
135 
136     ngx_hash_t                      hide_headers_hash;
137     ngx_array_t                    *hide_headers;
138     ngx_array_t                    *pass_headers;
139 
140     ngx_str_t                       schema;
141 
142     ngx_array_t                    *store_lengths;
143     ngx_array_t                    *store_values;
144 
145     signed                          store:2;
146     unsigned                        intercept_404:1;
147     unsigned                        change_buffering:1;
148 
149 #if (NGX_HTTP_SSL)
150     ngx_ssl_t                      *ssl;
151 #endif
152 
153 } ngx_http_upstream_conf_t;
154 
155 
156 typedef struct {
157     ngx_str_t                       name;
158     ngx_http_header_handler_pt      handler;
159     ngx_uint_t                      offset;
160     ngx_http_header_handler_pt      copy_handler;
161     ngx_uint_t                      conf;
162     ngx_uint_t                      redirect;  /* unsigned   redirect:1; */
163 } ngx_http_upstream_header_t;
164 
165 
166 typedef struct {
167     ngx_list_t                      headers;
168 
169     ngx_uint_t                      status_n;
170     ngx_str_t                       status_line;
171 
172     ngx_table_elt_t                *status;
173     ngx_table_elt_t                *date;
174     ngx_table_elt_t                *server;
175     ngx_table_elt_t                *connection;
176 
177     ngx_table_elt_t                *expires;
178     ngx_table_elt_t                *etag;
179     ngx_table_elt_t                *x_accel_expires;
180     ngx_table_elt_t                *x_accel_redirect;
181     ngx_table_elt_t                *x_accel_limit_rate;
182 
183     ngx_table_elt_t                *content_type;
184     ngx_table_elt_t                *content_length;
185 
186     ngx_table_elt_t                *last_modified;
187     ngx_table_elt_t                *location;
188     ngx_table_elt_t                *accept_ranges;
189     ngx_table_elt_t                *www_authenticate;
190 
191 #if (NGX_HTTP_GZIP)
192     ngx_table_elt_t                *content_encoding;
193 #endif
194 
195     off_t                           content_length_n;
196 
197     ngx_array_t                     cache_control;
198 } ngx_http_upstream_headers_in_t;
199 
200 
201 typedef struct {
202     ngx_str_t                       host;
203     in_port_t                       port;
204     ngx_uint_t                      naddrs;
205     in_addr_t                      *addrs;
206     ngx_resolver_ctx_t             *ctx;
207 } ngx_http_upstream_resolved_t;
208 
209 
210 struct ngx_http_upstream_s {
211     ngx_peer_connection_t           peer;
212 
213     ngx_event_pipe_t               *pipe;
214 
215     ngx_chain_t                    *request_bufs;
216 
217     ngx_output_chain_ctx_t          output;
218     ngx_chain_writer_ctx_t          writer;
219 
220     ngx_http_upstream_conf_t       *conf;
221 
222     ngx_http_upstream_headers_in_t  headers_in;
223 
224     ngx_http_upstream_resolved_t   *resolved;
225 
226     ngx_buf_t                       buffer;
227     size_t                          length;
228 
229     ngx_chain_t                    *out_bufs;
230     ngx_chain_t                    *busy_bufs;
231     ngx_chain_t                    *free_bufs;
232 
233     ngx_int_t                     (*input_filter_init)(void *data);
234     ngx_int_t                     (*input_filter)(void *data, ssize_t bytes);
235     void                           *input_filter_ctx;
236 
237     ngx_int_t                     (*create_request)(ngx_http_request_t *r);
238     ngx_int_t                     (*reinit_request)(ngx_http_request_t *r);
239     ngx_int_t                     (*process_header)(ngx_http_request_t *r);
240     void                          (*abort_request)(ngx_http_request_t *r);
241     void                          (*finalize_request)(ngx_http_request_t *r,
242                                         ngx_int_t rc);
243     ngx_int_t                     (*rewrite_redirect)(ngx_http_request_t *r,
244                                         ngx_table_elt_t *h, size_t prefix);
245 
246     ngx_msec_t                      timeout;
247 
248     ngx_http_upstream_state_t      *state;
249 
250     ngx_str_t                       method;
251     ngx_str_t                       schema;
252     ngx_str_t                       uri;
253 
254     ngx_http_cleanup_pt            *cleanup;
255 
256     unsigned                        store:1;
257     unsigned                        cacheable:1;
258     unsigned                        accel:1;
259     unsigned                        ssl:1;
260 
261     unsigned                        buffering:1;
262 
263     unsigned                        request_sent:1;
264     unsigned                        header_sent:1;
265 };
266 
267 
268 ngx_int_t ngx_http_upstream_header_variable(ngx_http_request_t *r,
269     ngx_http_variable_value_t *v, uintptr_t data);
270 
271 void ngx_http_upstream_init(ngx_http_request_t *r);
272 ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf,
273     ngx_url_t *u, ngx_uint_t flags);
274 ngx_int_t ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
275     ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
276     ngx_str_t *default_hide_headers, ngx_hash_init_t *hash);
277 
278 
279 #define ngx_http_conf_upstream_srv_conf(uscf, module)                         \
280     uscf->srv_conf[module.ctx_index]
281 
282 
283 extern ngx_module_t  ngx_http_upstream_module;
284 
285 
286 #endif /* _NGX_HTTP_UPSTREAM_H_INCLUDED_ */
287 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.