Update tutorial

This commit is contained in:
Tatsuhiro Tsujikawa 2014-04-05 18:04:21 +09:00
parent e7ad3633c7
commit 15e8d0de7b
1 changed files with 6 additions and 6 deletions

View File

@ -545,7 +545,7 @@ function to read content of the file::
static ssize_t file_read_callback static ssize_t file_read_callback
(nghttp2_session *session, int32_t stream_id, (nghttp2_session *session, int32_t stream_id,
uint8_t *buf, size_t length, int *eof, uint8_t *buf, size_t length, uint32_t *data_flags,
nghttp2_data_source *source, void *user_data) nghttp2_data_source *source, void *user_data)
{ {
int fd = source->fd; int fd = source->fd;
@ -555,16 +555,16 @@ function to read content of the file::
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE; return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
} }
if(r == 0) { if(r == 0) {
*eof = 1; *data_flags |= NGHTTP2_DATA_FLAG_EOF;
} }
return r; return r;
} }
If error happens while reading file, we return If error happens while reading file, we return
:macro:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. This tells the library :macro:`NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE`. This tells the
to send RST_STREAM to the stream. When all data is read, set 1 to library to send RST_STREAM to the stream. When all data are read, set
``*eof`` to tell the nghttp2 library that we have finished reading :macro:`NGHTTP2_DATA_FLAG_EOF` flag to ``*data_flags`` to tell the
file. nghttp2 library that we have finished reading file.
The `nghttp2_submit_response()` is used to send response to the remote The `nghttp2_submit_response()` is used to send response to the remote
peer. peer.