aboutsummaryrefslogtreecommitdiff
path: root/src/microspdy/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microspdy/session.c')
-rw-r--r--src/microspdy/session.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/microspdy/session.c b/src/microspdy/session.c
index 856bed85..7edebaba 100644
--- a/src/microspdy/session.c
+++ b/src/microspdy/session.c
@@ -325,14 +325,15 @@ spdyf_handler_read_rst_stream (struct SPDY_Session *session)
325static void 325static void
326spdyf_handler_read_data (struct SPDY_Session *session) 326spdyf_handler_read_data (struct SPDY_Session *session)
327{ 327{
328 //just ignore the whole frame for now 328 int ret;
329 struct SPDYF_Data_Frame * frame; 329 struct SPDYF_Data_Frame * frame;
330 struct SPDYF_Stream * stream;
330 331
331 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status 332 SPDYF_ASSERT(SPDY_SESSION_STATUS_WAIT_FOR_SUBHEADER == session->status
332 || SPDY_SESSION_STATUS_WAIT_FOR_BODY == session->status, 333 || SPDY_SESSION_STATUS_WAIT_FOR_BODY == session->status,
333 "the function is called wrong"); 334 "the function is called wrong");
334 335
335 SPDYF_DEBUG("DATA frame received (POST?). Ignoring"); 336 //SPDYF_DEBUG("DATA frame received (POST?). Ignoring");
336 337
337 //SPDYF_SIGINT(""); 338 //SPDYF_SIGINT("");
338 339
@@ -355,9 +356,41 @@ spdyf_handler_read_data (struct SPDY_Session *session)
355 if(session->read_buffer_offset - session->read_buffer_beginning 356 if(session->read_buffer_offset - session->read_buffer_beginning
356 >= frame->length) 357 >= frame->length)
357 { 358 {
358 session->read_buffer_beginning += frame->length; 359 stream = SPDYF_stream_find(frame->stream_id, session);
359 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER; 360
360 free(frame); 361 if(NULL == stream || stream->is_in_closed || NULL == session->daemon->received_data_cb)
362 {
363 if(NULL == session->daemon->received_data_cb)
364 SPDYF_DEBUG("No callback for DATA frame set");
365
366 SPDYF_DEBUG("Ignoring DATA frame!");
367
368 //TODO send error?
369
370 //TODO for now ignore frame
371 session->read_buffer_beginning += frame->length;
372 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER;
373 free(frame);
374 return;
375 }
376
377 ret = session->daemon->freceived_data_cb(session->daemon->cls,
378 stream,
379 session->read_buffer + session->read_buffer_beginning,
380 frame->length,
381 0 == (SPDY_DATA_FLAG_FIN & frame->flags));
382
383 session->read_buffer_beginning += frame->length;
384
385 //TODO close in and send rst maybe
386 SPDYF_ASSERT(SPDY_YES == ret, "Cancel POST data is not yet implemented");
387
388 if(SPDY_DATA_FLAG_FIN & frame->flags)
389 {
390 stream->is_in_closed = true;
391 }
392 session->status = SPDY_SESSION_STATUS_WAIT_FOR_HEADER;
393 free(frame);
361 } 394 }
362} 395}
363 396
@@ -1020,7 +1053,7 @@ SPDYF_session_write (struct SPDY_Session *session, bool only_one_frame)
1020 } 1053 }
1021 1054
1022 //set stream to closed if the frame's fin flag is set 1055 //set stream to closed if the frame's fin flag is set
1023 SPDYF_stream_set_flags(queue_head); 1056 SPDYF_stream_set_flags_on_write(queue_head);
1024 1057
1025 if(NULL != queue_head->frqcb) 1058 if(NULL != queue_head->frqcb)
1026 { 1059 {