comparison src/http/modules/proxy/ngx_http_proxy_handler.h @ 171:aff0e5d32af8

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