aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Uzunov <andrey.uzunov@gmail.com>2013-10-08 18:05:13 +0000
committerAndrey Uzunov <andrey.uzunov@gmail.com>2013-10-08 18:05:13 +0000
commitab4fa1fdbc51ec4d952b097f076ca0fdfcb10934 (patch)
tree65d8ef63816d870114ba80a44b33836e1186953d
parented542b8433247950099daa42295fd2610da16daf (diff)
downloadlibmicrohttpd-ab4fa1fdbc51ec4d952b097f076ca0fdfcb10934.tar.gz
libmicrohttpd-ab4fa1fdbc51ec4d952b097f076ca0fdfcb10934.zip
mhd2spdy: dont send duplicate RST_STREAMs
-rw-r--r--src/examples/mhd2spdy_http.c7
-rw-r--r--src/examples/mhd2spdy_spdy.c27
-rw-r--r--src/examples/mhd2spdy_structures.h1
3 files changed, 31 insertions, 4 deletions
diff --git a/src/examples/mhd2spdy_http.c b/src/examples/mhd2spdy_http.c
index bb951e8d..8116b326 100644
--- a/src/examples/mhd2spdy_http.c
+++ b/src/examples/mhd2spdy_http.c
@@ -148,7 +148,8 @@ http_cb_response (void *cls,
148static void 148static void
149http_cb_response_done(void *cls) 149http_cb_response_done(void *cls)
150{ 150{
151 151 (void)cls;
152 //TODO remove
152} 153}
153 154
154int 155int
@@ -370,6 +371,8 @@ http_cb_request_completed (void *cls,
370 void **con_cls, 371 void **con_cls,
371 enum MHD_RequestTerminationCode toe) 372 enum MHD_RequestTerminationCode toe)
372{ 373{
374 (void)cls;
375 (void)connection;
373 struct HTTP_URI *http_uri; 376 struct HTTP_URI *http_uri;
374 struct Proxy *proxy; 377 struct Proxy *proxy;
375 378
@@ -396,7 +399,7 @@ http_cb_request_completed (void *cls,
396 if(proxy->stream_id > 0 /*&& NULL != proxy->spdy_connection->session*/) 399 if(proxy->stream_id > 0 /*&& NULL != proxy->spdy_connection->session*/)
397 { 400 {
398 //send RST_STREAM_STATUS_CANCEL 401 //send RST_STREAM_STATUS_CANCEL
399 PRINT_INFO2("send rst_stream %i",proxy->spdy_active ); 402 PRINT_INFO2("send rst_stream %i %i",proxy->spdy_active, proxy->stream_id );
400 spdylay_submit_rst_stream(proxy->spdy_connection->session, proxy->stream_id, 5); 403 spdylay_submit_rst_stream(proxy->spdy_connection->session, proxy->stream_id, 5);
401 } 404 }
402 /*else 405 /*else
diff --git a/src/examples/mhd2spdy_spdy.c b/src/examples/mhd2spdy_spdy.c
index e7464c6a..17f170c1 100644
--- a/src/examples/mhd2spdy_spdy.c
+++ b/src/examples/mhd2spdy_spdy.c
@@ -147,6 +147,20 @@ spdy_cb_send(spdylay_session *session,
147 ssize_t rv; 147 ssize_t rv;
148 connection = (struct SPDY_Connection*)user_data; 148 connection = (struct SPDY_Connection*)user_data;
149 connection->want_io = IO_NONE; 149 connection->want_io = IO_NONE;
150
151 if(glob_opt.ignore_rst_stream
152 && 16 == length
153 && 0x80 == data[0]
154 && 0x00 == data[2]
155 && 0x03 == data[3]
156 )
157 {
158 PRINT_INFO2("ignoring RST_STREAM for stream_id %i %i %i %i", data[8], data[9], data[10], data[11]);
159 glob_opt.ignore_rst_stream = false;
160 return 16;
161 }
162 glob_opt.ignore_rst_stream = false;
163
150 if(connection->is_tls) 164 if(connection->is_tls)
151 { 165 {
152 ERR_clear_error(); 166 ERR_clear_error();
@@ -269,7 +283,7 @@ spdy_cb_recv(spdylay_session *session,
269 283
270 284
271static void 285static void
272spdy_cb_on_ctrl_send(spdylay_session *session, 286spdy_cb_before_ctrl_send(spdylay_session *session,
273 spdylay_frame_type type, 287 spdylay_frame_type type,
274 spdylay_frame *frame, 288 spdylay_frame *frame,
275 void *user_data) 289 void *user_data)
@@ -288,6 +302,15 @@ spdy_cb_on_ctrl_send(spdylay_session *session,
288 ++proxy->spdy_connection->streams_opened; 302 ++proxy->spdy_connection->streams_opened;
289 PRINT_INFO2("opening stream: str open %i; %s", glob_opt.streams_opened, proxy->url); 303 PRINT_INFO2("opening stream: str open %i; %s", glob_opt.streams_opened, proxy->url);
290 break; 304 break;
305 case SPDYLAY_RST_STREAM:
306 //try to ignore duplicate RST_STREAMs
307 //TODO this will ignore RST_STREAMs also for bogus data
308 glob_opt.ignore_rst_stream = NULL==spdylay_session_get_stream_user_data(session, frame->rst_stream.stream_id);
309 PRINT_INFO2("sending RST_STREAM for %i; ignore %i; status %i",
310 frame->rst_stream.stream_id,
311 glob_opt.ignore_rst_stream,
312 frame->rst_stream.status_code);
313 break;
291 default: 314 default:
292 break; 315 break;
293 } 316 }
@@ -465,7 +488,7 @@ spdy_setup_spdylay_callbacks(spdylay_session_callbacks *callbacks)
465 memset(callbacks, 0, sizeof(spdylay_session_callbacks)); 488 memset(callbacks, 0, sizeof(spdylay_session_callbacks));
466 callbacks->send_callback = spdy_cb_send; 489 callbacks->send_callback = spdy_cb_send;
467 callbacks->recv_callback = spdy_cb_recv; 490 callbacks->recv_callback = spdy_cb_recv;
468 callbacks->on_ctrl_send_callback = spdy_cb_on_ctrl_send; 491 callbacks->before_ctrl_send_callback = spdy_cb_before_ctrl_send;
469 callbacks->on_ctrl_recv_callback = spdy_cb_on_ctrl_recv; 492 callbacks->on_ctrl_recv_callback = spdy_cb_on_ctrl_recv;
470 callbacks->on_stream_close_callback = spdy_cb_on_stream_close; 493 callbacks->on_stream_close_callback = spdy_cb_on_stream_close;
471 callbacks->on_data_chunk_recv_callback = spdy_cb_on_data_chunk_recv; 494 callbacks->on_data_chunk_recv_callback = spdy_cb_on_data_chunk_recv;
diff --git a/src/examples/mhd2spdy_structures.h b/src/examples/mhd2spdy_structures.h
index ad75e0cc..8022d5ba 100644
--- a/src/examples/mhd2spdy_structures.h
+++ b/src/examples/mhd2spdy_structures.h
@@ -161,6 +161,7 @@ struct global_options
161 bool only_proxy; 161 bool only_proxy;
162 bool spdy_data_received; 162 bool spdy_data_received;
163 bool statistics; 163 bool statistics;
164 bool ignore_rst_stream;
164} 165}
165glob_opt; 166glob_opt;
166 167