Mercurial > hg > nginx
comparison src/http/modules/proxy/ngx_http_proxy_handler.h @ 170:c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 02 Nov 2003 22:56:18 +0000 |
parents | edf29bb717da |
children | aff0e5d32af8 |
comparison
equal
deleted
inserted
replaced
169:edf29bb717da | 170:c42be4185301 |
---|---|
3 | 3 |
4 | 4 |
5 #include <ngx_config.h> | 5 #include <ngx_config.h> |
6 #include <ngx_core.h> | 6 #include <ngx_core.h> |
7 #include <ngx_event.h> | 7 #include <ngx_event.h> |
8 #include <ngx_event_connect.h> | |
9 #include <ngx_event_pipe.h> | |
8 #include <ngx_http.h> | 10 #include <ngx_http.h> |
9 | 11 |
10 | 12 |
11 typedef struct { | 13 typedef struct { |
14 ngx_str_t url; | |
12 ngx_str_t host; | 15 ngx_str_t host; |
13 ngx_str_t uri; | 16 ngx_str_t uri; |
14 ngx_str_t host_header; | 17 ngx_str_t host_header; |
15 ngx_str_t port_text; | 18 ngx_str_t port_text; |
16 ngx_str_t *location; | 19 ngx_str_t *location; |
17 int port; | 20 int port; |
18 } ngx_http_proxy_upstream_t; | 21 } ngx_http_proxy_upstream_t; |
19 | 22 |
20 | 23 |
21 typedef struct { | 24 typedef struct { |
22 ssize_t request_buffer_size; | 25 ssize_t request_buffer_size; |
23 ngx_msec_t connect_timeout; | 26 ngx_msec_t connect_timeout; |
24 ngx_msec_t send_timeout; | 27 ngx_msec_t send_timeout; |
25 ssize_t header_buffer_size; | 28 ssize_t header_buffer_size; |
26 ngx_msec_t read_timeout; | 29 ngx_msec_t read_timeout; |
27 | 30 |
28 ngx_bufs_t bufs; | 31 ngx_bufs_t bufs; |
29 ssize_t busy_buffers_size; | 32 ssize_t busy_buffers_size; |
30 | 33 |
31 ssize_t max_temp_file_size; | 34 ssize_t max_temp_file_size; |
32 ssize_t temp_file_write_size; | 35 ssize_t temp_file_write_size; |
33 int cyclic_temp_file; | 36 int cyclic_temp_file; |
34 | 37 |
35 int pass_server; | 38 int cache; |
39 int pass_server; | |
36 | 40 |
37 int next_upstream; | 41 int next_upstream; |
42 int use_stale; | |
38 | 43 |
39 ngx_path_t *temp_path; | 44 ngx_path_t *cache_path; |
45 ngx_path_t *temp_path; | |
40 | 46 |
41 ngx_http_proxy_upstream_t *upstream; | 47 ngx_http_proxy_upstream_t *upstream; |
42 ngx_peers_t *peers; | 48 ngx_peers_t *peers; |
43 } ngx_http_proxy_loc_conf_t; | 49 } ngx_http_proxy_loc_conf_t; |
44 | 50 |
45 | 51 |
46 typedef struct { | 52 typedef struct { |
47 int status; | 53 int status; |
48 ngx_str_t *peer; | 54 ngx_str_t *peer; |
49 } ngx_http_proxy_state_t; | 55 } ngx_http_proxy_state_t; |
50 | 56 |
51 | 57 |
52 typedef struct { | 58 typedef struct { |
53 ngx_table_t *headers; /* it must be first field */ | 59 ngx_table_t *headers; /* it must be first field */ |
54 | 60 |
55 ngx_table_elt_t *date; | 61 ngx_table_elt_t *date; |
56 ngx_table_elt_t *server; | 62 ngx_table_elt_t *server; |
57 ngx_table_elt_t *connection; | 63 ngx_table_elt_t *connection; |
58 ngx_table_elt_t *content_type; | 64 ngx_table_elt_t *content_type; |
59 ngx_table_elt_t *content_length; | 65 ngx_table_elt_t *content_length; |
60 ngx_table_elt_t *last_modified; | 66 ngx_table_elt_t *last_modified; |
61 ngx_table_elt_t *accept_ranges; | 67 ngx_table_elt_t *accept_ranges; |
62 | 68 |
63 off_t content_length_n; | 69 off_t content_length_n; |
64 } ngx_http_proxy_headers_in_t; | 70 } ngx_http_proxy_headers_in_t; |
71 | |
72 | |
73 typedef struct { | |
74 ngx_http_cache_ctx_t ctx; | |
75 int status; | |
76 ngx_str_t status_line; | |
77 ngx_http_proxy_headers_in_t headers_in; | |
78 } ngx_http_proxy_cache_t; | |
65 | 79 |
66 | 80 |
67 typedef struct ngx_http_proxy_ctx_s ngx_http_proxy_ctx_t; | 81 typedef struct ngx_http_proxy_ctx_s ngx_http_proxy_ctx_t; |
68 | 82 |
69 struct ngx_http_proxy_ctx_s { | 83 struct ngx_http_proxy_ctx_s { |
70 ngx_peer_connection_t upstream; | 84 ngx_peer_connection_t upstream; |
71 ngx_peer_t *peer; | 85 ngx_peer_t *peer; |
72 | 86 |
73 ngx_http_request_t *request; | 87 ngx_http_request_t *request; |
74 ngx_http_proxy_loc_conf_t *lcf; | 88 ngx_http_proxy_loc_conf_t *lcf; |
89 ngx_http_proxy_cache_t *cache; | |
75 ngx_http_proxy_headers_in_t headers_in; | 90 ngx_http_proxy_headers_in_t headers_in; |
76 | 91 |
77 ngx_hunk_t *header_in; | 92 ngx_hunk_t *header_in; |
78 int status; | 93 int status; |
79 ngx_str_t status_line; | 94 ngx_str_t status_line; |
80 | 95 |
81 ngx_output_chain_ctx_t *output_chain_ctx; | 96 ngx_output_chain_ctx_t *output_chain_ctx; |
82 | 97 |
83 int method; | 98 int method; |
84 | 99 |
85 ngx_event_pipe_t *event_pipe; | 100 ngx_event_pipe_t *event_pipe; |
86 | 101 |
87 unsigned accel:1; | 102 unsigned accel:1; |
88 unsigned cachable:1; | 103 |
89 unsigned fatal_error:1; | 104 unsigned cachable:1; |
90 unsigned request_sent:1; | 105 unsigned stale:1; |
91 unsigned timedout:1; | 106 |
92 unsigned header_sent:1; | 107 unsigned request_sent:1; |
108 unsigned header_sent:1; | |
93 | 109 |
94 /* used to parse an upstream HTTP header */ | 110 /* used to parse an upstream HTTP header */ |
95 char *status_start; | 111 char *status_start; |
96 char *status_end; | 112 char *status_end; |
97 int status_count; | 113 int status_count; |
98 int state; | 114 int state; |
99 | 115 |
100 ngx_array_t states; /* of ngx_http_proxy_state_t */ | 116 ngx_array_t states; /* of ngx_http_proxy_state_t */ |
101 | 117 |
102 char *action; | 118 char *action; |
103 ngx_http_log_ctx_t *saved_ctx; | 119 ngx_http_log_ctx_t *saved_ctx; |
104 ngx_log_handler_pt saved_handler; | 120 ngx_log_handler_pt saved_handler; |
105 }; | 121 }; |
106 | 122 |
107 | 123 |
108 #define NGX_HTTP_PROXY_PARSE_NO_HEADER 20 | 124 #define NGX_STALE 1 |
109 | 125 |
110 #define NGX_HTTP_PROXY_FT_ERROR 1 | 126 #define NGX_HTTP_PROXY_PARSE_NO_HEADER 20 |
111 #define NGX_HTTP_PROXY_FT_TIMEOUT 2 | 127 |
112 #define NGX_HTTP_PROXY_FT_HTTP_HEADER 4 | 128 #define NGX_HTTP_PROXY_FT_ERROR 2 |
113 #define NGX_HTTP_PROXY_FT_HTTP_500 8 | 129 #define NGX_HTTP_PROXY_FT_TIMEOUT 4 |
130 #define NGX_HTTP_PROXY_FT_INVALID_HEADER 8 | |
131 #define NGX_HTTP_PROXY_FT_HTTP_500 16 | |
132 #define NGX_HTTP_PROXY_FT_HTTP_404 32 | |
133 #define NGX_HTTP_PROXY_FT_BUSY_LOCK 64 | |
134 #define NGX_HTTP_PROXY_FT_MAX_WAITING 128 | |
135 | |
136 | |
137 void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p); | |
138 | |
139 int ngx_http_proxy_get_cached_response(ngx_http_proxy_ctx_t *p); | |
140 int ngx_http_proxy_process_cached_response(ngx_http_proxy_ctx_t *p); | |
141 int ngx_http_proxy_send_cached_response(ngx_http_proxy_ctx_t *p); | |
142 | |
143 int ngx_http_proxy_parse_status_line(ngx_http_proxy_ctx_t *p); | |
144 int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p, | |
145 ngx_http_proxy_headers_in_t *headers_in); | |
146 | |
147 | |
148 | |
149 extern ngx_module_t ngx_http_proxy_module; | |
150 extern ngx_http_header_t ngx_http_proxy_headers_in[]; | |
151 | |
114 | 152 |
115 | 153 |
116 #endif /* _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_ */ | 154 #endif /* _NGX_HTTP_PROXY_HANDLER_H_INCLUDED_ */ |