diff options
Diffstat (limited to 'src/examples/mhd2spdy_http.c')
-rw-r--r-- | src/examples/mhd2spdy_http.c | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/examples/mhd2spdy_http.c b/src/examples/mhd2spdy_http.c index 1f7dec97..cf9f6c52 100644 --- a/src/examples/mhd2spdy_http.c +++ b/src/examples/mhd2spdy_http.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | 28 | ||
29 | void * | 29 | void * |
30 | http_log_cb(void * cls, | 30 | http_cb_log(void * cls, |
31 | const char * uri) | 31 | const char * uri) |
32 | { | 32 | { |
33 | (void)cls; | 33 | (void)cls; |
@@ -45,7 +45,7 @@ const char * uri) | |||
45 | 45 | ||
46 | 46 | ||
47 | static int | 47 | static int |
48 | http_iterate_cb(void *cls, | 48 | http_cb_iterate(void *cls, |
49 | enum MHD_ValueKind kind, | 49 | enum MHD_ValueKind kind, |
50 | const char *name, | 50 | const char *name, |
51 | const char *value) | 51 | const char *value) |
@@ -76,7 +76,7 @@ http_iterate_cb(void *cls, | |||
76 | 76 | ||
77 | 77 | ||
78 | static ssize_t | 78 | static ssize_t |
79 | http_response_callback (void *cls, | 79 | http_cb_response (void *cls, |
80 | uint64_t pos, | 80 | uint64_t pos, |
81 | char *buffer, | 81 | char *buffer, |
82 | size_t max) | 82 | size_t max) |
@@ -89,9 +89,9 @@ http_response_callback (void *cls, | |||
89 | const union MHD_ConnectionInfo *info; | 89 | const union MHD_ConnectionInfo *info; |
90 | int val = 1; | 90 | int val = 1; |
91 | 91 | ||
92 | PRINT_INFO2("http_response_callback for %s", proxy->url); | 92 | PRINT_INFO2("http_cb_response for %s", proxy->url); |
93 | 93 | ||
94 | if(proxy->error) | 94 | if(proxy->spdy_error) |
95 | return MHD_CONTENT_READER_END_WITH_ERROR; | 95 | return MHD_CONTENT_READER_END_WITH_ERROR; |
96 | 96 | ||
97 | if(0 == proxy->http_body_size &&( proxy->done || !proxy->spdy_active)){ | 97 | if(0 == proxy->http_body_size &&( proxy->done || !proxy->spdy_active)){ |
@@ -145,18 +145,15 @@ http_response_callback (void *cls, | |||
145 | 145 | ||
146 | 146 | ||
147 | static void | 147 | static void |
148 | http_response_done_callback(void *cls) | 148 | http_cb_response_done(void *cls) |
149 | { | 149 | { |
150 | struct Proxy *proxy = (struct Proxy *)cls; | ||
151 | 150 | ||
152 | PRINT_INFO2("http_response_done_callback for %s", proxy->url); | 151 | //TODO |
152 | /*struct Proxy *proxy = (struct Proxy *)cls; | ||
153 | 153 | ||
154 | if(proxy->spdy_active) | 154 | PRINT_INFO2("http_cb_response_done for %s", proxy->url); |
155 | proxy->http_active = false; | 155 | */ |
156 | else | ||
157 | free_proxy(proxy); | ||
158 | 156 | ||
159 | --glob_opt.responses_pending; | ||
160 | } | 157 | } |
161 | 158 | ||
162 | int | 159 | int |
@@ -291,7 +288,7 @@ http_cb_request (void *cls, | |||
291 | spdy_headers.cnt = 10; | 288 | spdy_headers.cnt = 10; |
292 | MHD_get_connection_values (connection, | 289 | MHD_get_connection_values (connection, |
293 | MHD_HEADER_KIND, | 290 | MHD_HEADER_KIND, |
294 | &http_iterate_cb, | 291 | &http_cb_iterate, |
295 | &spdy_headers); | 292 | &spdy_headers); |
296 | 293 | ||
297 | spdy_headers.nv[spdy_headers.cnt] = NULL; | 294 | spdy_headers.nv[spdy_headers.cnt] = NULL; |
@@ -309,9 +306,9 @@ http_cb_request (void *cls, | |||
309 | 306 | ||
310 | proxy->http_response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, | 307 | proxy->http_response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN, |
311 | 4096, | 308 | 4096, |
312 | &http_response_callback, | 309 | &http_cb_response, |
313 | proxy, | 310 | proxy, |
314 | &http_response_done_callback); | 311 | &http_cb_response_done); |
315 | 312 | ||
316 | if (proxy->http_response == NULL) | 313 | if (proxy->http_response == NULL) |
317 | DIE("no response"); | 314 | DIE("no response"); |
@@ -371,3 +368,33 @@ http_create_response(struct Proxy* proxy, | |||
371 | 368 | ||
372 | MHD_destroy_response (proxy->http_response); | 369 | MHD_destroy_response (proxy->http_response); |
373 | } | 370 | } |
371 | |||
372 | void | ||
373 | http_cb_request_completed (void *cls, | ||
374 | struct MHD_Connection *connection, | ||
375 | void **con_cls, | ||
376 | enum MHD_RequestTerminationCode toe) | ||
377 | { | ||
378 | struct HTTP_URI *http_uri = (struct HTTP_URI *)*con_cls; | ||
379 | if(NULL == http_uri) return; | ||
380 | struct Proxy *proxy = (struct Proxy *)http_uri->proxy; | ||
381 | |||
382 | PRINT_INFO2("http_cb_request_completed %i for %s",toe, http_uri->uri); | ||
383 | |||
384 | if(proxy->spdy_active) | ||
385 | { | ||
386 | proxy->http_active = false; | ||
387 | if(MHD_REQUEST_TERMINATED_COMPLETED_OK != toe) | ||
388 | { | ||
389 | proxy->http_error = true; | ||
390 | assert(proxy->stream_id > 0); | ||
391 | //send RST_STREAM_STATUS_CANCEL | ||
392 | PRINT_INFO("send rst_stream" ); | ||
393 | spdylay_submit_rst_stream(proxy->spdy_connection->session, proxy->stream_id, 5); | ||
394 | } | ||
395 | } | ||
396 | else | ||
397 | free_proxy(proxy); | ||
398 | |||
399 | --glob_opt.responses_pending; | ||
400 | } | ||