libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 52067ffbfe51995cafcb13fe36b1a36cff3e857c
parent ae1feacf2aee18d1fd2627a495ec08c64cac102c
Author: Andrey Uzunov <andrey.uzunov@gmail.com>
Date:   Thu, 10 Oct 2013 21:50:28 +0000

spdy2http: send Bad Gateway when curl encounters network problem

Diffstat:
Msrc/spdy2http/proxy.c | 45+++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/src/spdy2http/proxy.c b/src/spdy2http/proxy.c @@ -1173,7 +1173,7 @@ run () else { PRINT_VERBOSE2("bad curl result (%i) for '%s'", msg->data.result, proxy->url); - if(proxy->spdy_done || proxy->spdy_error || NULL == proxy->response) + if(proxy->spdy_done || proxy->spdy_error || (NULL == proxy->response && !*(proxy->session_alive))) { PRINT_VERBOSE("cleaning"); SPDY_name_value_destroy(proxy->headers); @@ -1181,32 +1181,37 @@ run () SPDY_destroy_response(proxy->response); cleanup(proxy); } - else - { - proxy->curl_error = true; - } - /*if(NULL == proxy->response) + else if(NULL == proxy->response && *(proxy->session_alive)) { + //generate error for the client + PRINT_VERBOSE("will send Bad Gateway"); SPDY_name_value_destroy(proxy->headers); - *//*if(!*(proxy->session_alive)) + proxy->headers = NULL; + if(NULL == (proxy->response = SPDY_build_response(SPDY_HTTP_BAD_GATEWAY, + NULL, + SPDY_HTTP_VERSION_1_1, + NULL, + ERROR_RESPONSE, + strlen(ERROR_RESPONSE)))) + DIE("no response"); + if(SPDY_YES != SPDY_queue_response(proxy->request, + proxy->response, + true, + false, + &response_done_callback, + proxy)) { - free(proxy->http_body); - proxy->http_body = NULL; -*//* + //clean and forget + PRINT_VERBOSE("cleaning"); SPDY_destroy_request(proxy->request); + SPDY_destroy_response(proxy->response); cleanup(proxy); - *//*} - else - proxy->error = true;*/ - /* } + } + } else { - //TODO too early to clean them - proxy->error = true; - //SPDY_destroy_request(proxy->request); - //SPDY_destroy_response(proxy->response); - //cleanup(proxy); - }*/ + proxy->curl_error = true; + } call_spdy_run = true; //TODO spdy should be notified to send RST_STREAM }