diff --git a/examples/SpdyServer.cc b/examples/SpdyServer.cc index d9b8200..c8c93a9 100644 --- a/examples/SpdyServer.cc +++ b/examples/SpdyServer.cc @@ -367,7 +367,8 @@ ssize_t hd_recv_callback(spdylay_session *session, } // namespace ssize_t file_read_callback -(spdylay_session *session, uint8_t *buf, size_t length, int *eof, +(spdylay_session *session, int32_t stream_id, + uint8_t *buf, size_t length, int *eof, spdylay_data_source *source, void *user_data) { int fd = source->fd; diff --git a/examples/SpdyServer.h b/examples/SpdyServer.h index 1512c35..b76dd33 100644 --- a/examples/SpdyServer.h +++ b/examples/SpdyServer.h @@ -152,7 +152,8 @@ void htdocs_on_request_recv_callback (spdylay_session *session, int32_t stream_id, void *user_data); ssize_t file_read_callback -(spdylay_session *session, uint8_t *buf, size_t length, int *eof, +(spdylay_session *session, int32_t stream_id, + uint8_t *buf, size_t length, int *eof, spdylay_data_source *source, void *user_data); } // namespace spdylay diff --git a/examples/spdy.h b/examples/spdy.h index ea883d7..ba3782c 100644 --- a/examples/spdy.h +++ b/examples/spdy.h @@ -135,7 +135,8 @@ private: }; ssize_t string_read_callback -(spdylay_session *session, uint8_t *buf, size_t length, int *eof, +(spdylay_session *session, int32_t stream_id, + uint8_t *buf, size_t length, int *eof, spdylay_data_source *source, void *user_data) { std::pair& body_pair = diff --git a/lib/includes/spdylay/spdylay.h b/lib/includes/spdylay/spdylay.h index 05a70bc..fc9db3d 100644 --- a/lib/includes/spdylay/spdylay.h +++ b/lib/includes/spdylay/spdylay.h @@ -182,20 +182,22 @@ typedef union { /* * Callback function invoked when the library wants to read data from - * |source|. The implementation of this function must read at most - * |length| bytes of data from |source| (or possibly other places) and - * store them in |buf| and return number of data stored in |buf|. If - * EOF is reached, set |*eof| to 1. If the application wants to - * postpone DATA frames, (e.g., asynchronous I/O, or reading data - * blocks for long time), it is achieved by returning - * SPDYLAY_ERR_DEFERRED without reading any data in this invocation. - * The library removes DATA frame from outgoing queue temporarily. To - * move back deferred DATA frame to outgoing queue, call - * spdylay_session_resume_data(). In case of error, return - * SPDYLAY_ERR_CALLBACK_FAILURE, which leads to session failure. + * |source|. The read data is sent in the stream |stream_id|. The + * implementation of this function must read at most |length| bytes of + * data from |source| (or possibly other places) and store them in + * |buf| and return number of data stored in |buf|. If EOF is reached, + * set |*eof| to 1. If the application wants to postpone DATA frames, + * (e.g., asynchronous I/O, or reading data blocks for long time), it + * is achieved by returning SPDYLAY_ERR_DEFERRED without reading any + * data in this invocation. The library removes DATA frame from + * outgoing queue temporarily. To move back deferred DATA frame to + * outgoing queue, call spdylay_session_resume_data(). In case of + * error, return SPDYLAY_ERR_CALLBACK_FAILURE, which leads to session + * failure. */ typedef ssize_t (*spdylay_data_source_read_callback) -(spdylay_session *session, uint8_t *buf, size_t length, int *eof, +(spdylay_session *session, int32_t stream_id, + uint8_t *buf, size_t length, int *eof, spdylay_data_source *source, void *user_data); typedef struct { diff --git a/lib/spdylay_session.c b/lib/spdylay_session.c index ee61f83..ec6fcf9 100644 --- a/lib/spdylay_session.c +++ b/lib/spdylay_session.c @@ -1686,7 +1686,8 @@ ssize_t spdylay_session_pack_data_overwrite(spdylay_session *session, int eof = 0; uint8_t flags = 0; r = frame->data_prd.read_callback - (session, buf+8, len-8, &eof, &frame->data_prd.source, session->user_data); + (session, frame->stream_id, buf+8, len-8, &eof, &frame->data_prd.source, + session->user_data); if(r < 0) { return r; } else if(len < r) { diff --git a/tests/spdylay_session_test.c b/tests/spdylay_session_test.c index d0a18bc..50524ee 100644 --- a/tests/spdylay_session_test.c +++ b/tests/spdylay_session_test.c @@ -138,7 +138,8 @@ static void on_ctrl_send_callback(spdylay_session *session, } static ssize_t fixed_length_data_source_read_callback -(spdylay_session *session, uint8_t *buf, size_t len, int *eof, +(spdylay_session *session, int32_t stream_id, + uint8_t *buf, size_t len, int *eof, spdylay_data_source *source, void *user_data) { my_user_data *ud = (my_user_data*)user_data; @@ -1274,7 +1275,8 @@ void test_spdylay_session_recv_invalid_frame() } static ssize_t defer_data_source_read_callback -(spdylay_session *session, uint8_t *buf, size_t len, int *eof, +(spdylay_session *session, int32_t stream_id, + uint8_t *buf, size_t len, int *eof, spdylay_data_source *source, void *user_data) { return SPDYLAY_ERR_DEFERRED;