comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 124:842a78cebbb7

nginx-0.0.1-2003-08-01-18:56:33 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 01 Aug 2003 14:56:33 +0000
parents
children 049e78b1f852
comparison
equal deleted inserted replaced
123:b75602822f64 124:842a78cebbb7
1
2 #include <ngx_config.h>
3 #include <ngx_core.h>
4 #include <ngx_event.h>
5 /* STUB */ #include <ngx_event_connect.h>
6 #include <ngx_http.h>
7 #include <ngx_http_proxy_handler.h>
8
9
10
11 static ngx_command_t ngx_http_proxy_commands[] = {
12 ngx_null_command
13 };
14
15
16 ngx_http_module_t ngx_http_proxy_module_ctx = {
17 NULL, /* create main configuration */
18 NULL, /* init main configuration */
19
20 NULL, /* create server configuration */
21 NULL, /* merge server configuration */
22
23 #if 0
24 ngx_http_proxy_create_conf, /* create location configration */
25 ngx_http_proxy_merge_conf /* merge location configration */
26 #endif
27
28 NULL,
29 NULL
30 };
31
32
33 ngx_module_t ngx_http_proxy_module = {
34 NGX_MODULE,
35 &ngx_http_proxy_module_ctx, /* module context */
36 ngx_http_proxy_commands, /* module directives */
37 NGX_HTTP_MODULE, /* module type */
38 NULL, /* init module */
39 NULL /* init child */
40 };
41
42
43 #if 0
44 static
45 #endif
46
47 int ngx_http_proxy_handler(ngx_http_request_t *r)
48 {
49 int rc;
50 ngx_http_proxy_ctx_t *p;
51 ngx_peer_connection_t *pc;
52
53
54 ngx_http_create_ctx(r, p, ngx_http_proxy_module,
55 sizeof(ngx_http_proxy_ctx_t),
56 NGX_HTTP_INTERNAL_SERVER_ERROR);
57
58
59 p->action = "connecting to upstream";
60 p->request = r;
61
62
63 #if 0
64 pc->peers = lcf->peers;
65 #endif
66
67 p->upstream.log = r->connection->log;
68
69 do {
70 rc = ngx_event_connect_peer(&p->upstream);
71
72 if (rc == NGX_ERROR) {
73 return NGX_HTTP_INTERNAL_SERVER_ERROR;
74 }
75
76 if (rc == NGX_OK) {
77 send_proxy_request(p);
78 return NGX_OK;
79 }
80
81 if (rc == NGX_AGAIN && p->upstream.connection) {
82 return NGX_OK;
83 }
84
85 } while (p->upstream.tries);
86
87 return NGX_HTTP_BAD_GATEWAY;
88 }
89
90
91 #if 0
92
93 ngx_http_proxy_connect()
94 do {
95 ngx_event_connect_peer()
96 if error
97 return error
98 if ok
99 return ok
100 if again
101 return again
102
103 /* next */
104 while (tries)
105 }
106
107
108 ngx_http_proxy_send_request(ngx_event_t *wev)
109 for ( ;; ) {
110 send
111 if ok
112 ???
113 if again
114 return
115 if error
116 close
117 ngx_http_proxy_connect()
118 if ok
119 continue
120 if error
121 return
122 if again
123 return
124 }
125
126 #endif
127
128
129 static size_t ngx_http_proxy_log_error(void *data, char *buf, size_t len)
130 {
131 ngx_http_proxy_ctx_t *p = data;
132
133 return ngx_snprintf(buf, len,
134 " while %s, upstream: %s, client: %s, URL: %s",
135 p->action,
136 p->upstream.peers->peers[p->upstream.cur_peer].addr_port_text.data,
137 p->request->connection->addr_text.data,
138 p->request->unparsed_uri.data);
139 }