From 7d699ea73c7a54832471e659bbeb6b26007f1f07 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Tue, 14 Jan 2014 13:27:00 +0000 Subject: [PATCH] Added URI handler return value --- docs/API.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/API.md b/docs/API.md index 019f0c32..9fb343b7 100644 --- a/docs/API.md +++ b/docs/API.md @@ -82,7 +82,14 @@ whether the request is websocket or not. Also, for websocket requests, there is `struct mg_connection::wsbits` field which contains first byte of the websocket frame which URI handler can examine. Note that to reply to the websocket client, `mg_websocket_write()` should be used. -To reply to the plain HTTP client, `mg_write()` should be used. +To reply to the plain HTTP client, `mg_write_data()` should be used. + +An URI handler must return a value. If 0 is return, that signals Mongoose +that URI handler hasn't finished sending data to the client. In this case, +Mongoose will call URI handler after each successful socket write. +`struct mg_connection::wsbits` flag will indicate the status of the write, +`1` means that write has failed and connection will be closed. If URI +handler has sent all data, it should return `1`. void mg_set_http_error_handler(struct mg_server *, mg_handler_t);