diff options
author | Andrey Uzunov <andrey.uzunov@gmail.com> | 2013-10-10 21:50:28 +0000 |
---|---|---|
committer | Andrey Uzunov <andrey.uzunov@gmail.com> | 2013-10-10 21:50:28 +0000 |
commit | 52067ffbfe51995cafcb13fe36b1a36cff3e857c (patch) | |
tree | 9d00a0feab0947ddb9ec08e95e88e2c42d2ea428 | |
parent | ae1feacf2aee18d1fd2627a495ec08c64cac102c (diff) | |
download | libmicrohttpd-52067ffbfe51995cafcb13fe36b1a36cff3e857c.tar.gz libmicrohttpd-52067ffbfe51995cafcb13fe36b1a36cff3e857c.zip |
spdy2http: send Bad Gateway when curl encounters network problem
-rw-r--r-- | src/spdy2http/proxy.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/spdy2http/proxy.c b/src/spdy2http/proxy.c index 69a502f4..c317588a 100644 --- a/src/spdy2http/proxy.c +++ b/src/spdy2http/proxy.c | |||
@@ -1173,7 +1173,7 @@ run () | |||
1173 | else | 1173 | else |
1174 | { | 1174 | { |
1175 | PRINT_VERBOSE2("bad curl result (%i) for '%s'", msg->data.result, proxy->url); | 1175 | PRINT_VERBOSE2("bad curl result (%i) for '%s'", msg->data.result, proxy->url); |
1176 | if(proxy->spdy_done || proxy->spdy_error || NULL == proxy->response) | 1176 | if(proxy->spdy_done || proxy->spdy_error || (NULL == proxy->response && !*(proxy->session_alive))) |
1177 | { | 1177 | { |
1178 | PRINT_VERBOSE("cleaning"); | 1178 | PRINT_VERBOSE("cleaning"); |
1179 | SPDY_name_value_destroy(proxy->headers); | 1179 | SPDY_name_value_destroy(proxy->headers); |
@@ -1181,32 +1181,37 @@ run () | |||
1181 | SPDY_destroy_response(proxy->response); | 1181 | SPDY_destroy_response(proxy->response); |
1182 | cleanup(proxy); | 1182 | cleanup(proxy); |
1183 | } | 1183 | } |
1184 | else | 1184 | else if(NULL == proxy->response && *(proxy->session_alive)) |
1185 | { | ||
1186 | proxy->curl_error = true; | ||
1187 | } | ||
1188 | /*if(NULL == proxy->response) | ||
1189 | { | 1185 | { |
1186 | //generate error for the client | ||
1187 | PRINT_VERBOSE("will send Bad Gateway"); | ||
1190 | SPDY_name_value_destroy(proxy->headers); | 1188 | SPDY_name_value_destroy(proxy->headers); |
1191 | *//*if(!*(proxy->session_alive)) | 1189 | proxy->headers = NULL; |
1190 | if(NULL == (proxy->response = SPDY_build_response(SPDY_HTTP_BAD_GATEWAY, | ||
1191 | NULL, | ||
1192 | SPDY_HTTP_VERSION_1_1, | ||
1193 | NULL, | ||
1194 | ERROR_RESPONSE, | ||
1195 | strlen(ERROR_RESPONSE)))) | ||
1196 | DIE("no response"); | ||
1197 | if(SPDY_YES != SPDY_queue_response(proxy->request, | ||
1198 | proxy->response, | ||
1199 | true, | ||
1200 | false, | ||
1201 | &response_done_callback, | ||
1202 | proxy)) | ||
1192 | { | 1203 | { |
1193 | free(proxy->http_body); | 1204 | //clean and forget |
1194 | proxy->http_body = NULL; | 1205 | PRINT_VERBOSE("cleaning"); |
1195 | *//* | ||
1196 | SPDY_destroy_request(proxy->request); | 1206 | SPDY_destroy_request(proxy->request); |
1207 | SPDY_destroy_response(proxy->response); | ||
1197 | cleanup(proxy); | 1208 | cleanup(proxy); |
1198 | *//*} | 1209 | } |
1199 | else | 1210 | } |
1200 | proxy->error = true;*/ | ||
1201 | /* } | ||
1202 | else | 1211 | else |
1203 | { | 1212 | { |
1204 | //TODO too early to clean them | 1213 | proxy->curl_error = true; |
1205 | proxy->error = true; | 1214 | } |
1206 | //SPDY_destroy_request(proxy->request); | ||
1207 | //SPDY_destroy_response(proxy->response); | ||
1208 | //cleanup(proxy); | ||
1209 | }*/ | ||
1210 | call_spdy_run = true; | 1215 | call_spdy_run = true; |
1211 | //TODO spdy should be notified to send RST_STREAM | 1216 | //TODO spdy should be notified to send RST_STREAM |
1212 | } | 1217 | } |