| 85 int ref; |
85 int ref; |
| 86 } ProxyRequest; |
86 } ProxyRequest; |
| 87 |
87 |
| 88 static void proxy_unref(ProxyRequest *proxy) { |
88 static void proxy_unref(ProxyRequest *proxy) { |
| 89 if(--proxy->ref == 0) { |
89 if(--proxy->ref == 0) { |
| |
90 log_ereport(LOG_INFORM, "proxy cleanup"); |
| 90 //const char *method = pblock_findkeyval(pb_key_method, proxy->rq->reqpb); |
91 //const char *method = pblock_findkeyval(pb_key_method, proxy->rq->reqpb); |
| 91 //const char *uri = pblock_findkeyval(pb_key_uri, proxy->rq->reqpb); |
92 //const char *uri = pblock_findkeyval(pb_key_uri, proxy->rq->reqpb); |
| 92 //log_ereport(LOG_INFORM, "reverse-proxy: %s %s finished", method, uri); |
93 //log_ereport(LOG_INFORM, "reverse-proxy: %s %s finished", method, uri); |
| 93 http_client_free(proxy->client); |
94 http_client_free(proxy->client); |
| 94 free(proxy->read_buf); |
95 free(proxy->read_buf); |
| 139 } |
140 } |
| 140 |
141 |
| 141 static void proxy_response_finished(HttpClient *client, void *userdata) { |
142 static void proxy_response_finished(HttpClient *client, void *userdata) { |
| 142 ProxyRequest *proxy = userdata; |
143 ProxyRequest *proxy = userdata; |
| 143 |
144 |
| |
145 log_ereport(LOG_INFORM, "proxy_response_finished: %s", client->uri); |
| |
146 |
| 144 int ret = REQ_PROCEED; |
147 int ret = REQ_PROCEED; |
| 145 if(!proxy->response_started) { |
148 if(!proxy->response_started) { |
| 146 protocol_status(proxy->sn, proxy->rq, 502, NULL); |
149 protocol_status(proxy->sn, proxy->rq, 502, NULL); |
| 147 ret = REQ_ABORTED; |
150 ret = REQ_ABORTED; |
| 148 } |
151 } |
| 168 if(http_client_process(proxy->client, event)) { |
171 if(http_client_process(proxy->client, event)) { |
| 169 if(proxy->client->error == 0) { |
172 if(proxy->client->error == 0) { |
| 170 return 1; |
173 return 1; |
| 171 } |
174 } |
| 172 } |
175 } |
| |
176 log_ereport(LOG_INFORM, "proxy_event end: %p", event->finish); |
| 173 return 0; |
177 return 0; |
| 174 } |
178 } |
| 175 |
179 |
| 176 static int proxy_event_finished(EventHandler *eh, Event *event) { |
180 static int proxy_event_finished(EventHandler *eh, Event *event) { |
| 177 ProxyRequest *proxy = event->cookie; |
181 ProxyRequest *proxy = event->cookie; |