aboutsummaryrefslogtreecommitdiff
path: root/src/examples/chunked_example.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-07-25 12:49:25 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-07-25 12:51:24 +0300
commit09ccb6f7da257cfd6217c9254f90bf759187348e (patch)
tree33e96c52811dcfe2ec9865570af56928e3cec6f2 /src/examples/chunked_example.c
parent5d497ac69913da3efd489e9443b25ca76d57c2bb (diff)
downloadlibmicrohttpd-09ccb6f7da257cfd6217c9254f90bf759187348e.tar.gz
libmicrohttpd-09ccb6f7da257cfd6217c9254f90bf759187348e.zip
chunked_example.c: added pseudo code to complete picture
Diffstat (limited to 'src/examples/chunked_example.c')
-rw-r--r--src/examples/chunked_example.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/examples/chunked_example.c b/src/examples/chunked_example.c
index cec20910..3cd008df 100644
--- a/src/examples/chunked_example.c
+++ b/src/examples/chunked_example.c
@@ -20,6 +20,7 @@
20 * @file chunked_example.c 20 * @file chunked_example.c
21 * @brief example for generating chunked encoding with libmicrohttpd 21 * @brief example for generating chunked encoding with libmicrohttpd
22 * @author Christian Grothoff 22 * @author Christian Grothoff
23 * @author Karlson2k (Evgeny Grin)
23 */ 24 */
24 25
25#include "platform.h" 26#include "platform.h"
@@ -44,12 +45,31 @@ callback (void *cls,
44 return MHD_CONTENT_READER_END_OF_STREAM; 45 return MHD_CONTENT_READER_END_OF_STREAM;
45 } 46 }
46 47
48 /* Pseudo code. *
49 if (data_not_ready)
50 {
51 // Callback will be called again on next loop.
52 // Consider suspending connection until data will be ready.
53 return 0;
54 }
55 * End of pseudo code. */
56
47 if (buf_size < (response_size - pos) ) 57 if (buf_size < (response_size - pos) )
48 size_to_copy = buf_size; 58 size_to_copy = buf_size;
49 else 59 else
50 size_to_copy = response_size - pos; 60 size_to_copy = response_size - pos;
51 61
52 memcpy (buf, response_data + pos, size_to_copy); 62 memcpy (buf, response_data + pos, size_to_copy);
63
64 /* Pseudo code. *
65 if (error_preparing_response)
66 {
67 // Close connection with error.
68 return MHD_CONTENT_READER_END_WITH_ERROR;
69 }
70 * End of pseudo code. */
71
72 /* Return amount of data copied to buffer. */
53 return size_to_copy; 73 return size_to_copy;
54} 74}
55 75