diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-05-29 15:19:00 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2017-05-29 15:22:42 +0300 |
commit | 15dfade0d5ad728b26a08b63831f975e2700f729 (patch) | |
tree | e27b97a7c954e4655c1841667b4443efc7716553 /src/examples | |
parent | 69d990f4f8cf213132b361bb548986c6ce931d0b (diff) | |
download | libmicrohttpd-15dfade0d5ad728b26a08b63831f975e2700f729.tar.gz libmicrohttpd-15dfade0d5ad728b26a08b63831f975e2700f729.zip |
examples/timeout.c: Converted newline chars to Unix format
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/timeout.c | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/src/examples/timeout.c b/src/examples/timeout.c index 6a9a1e3e..e0e33560 100644 --- a/src/examples/timeout.c +++ b/src/examples/timeout.c | |||
@@ -1,78 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libmicrohttpd | 2 | This file is part of libmicrohttpd |
3 | Copyright (C) 2016, 2017 Christian Grothoff, | 3 | Copyright (C) 2016, 2017 Christian Grothoff, |
4 | Silvio Clecio (silvioprog), Karlson2k (Evgeny Grin) | 4 | Silvio Clecio (silvioprog), Karlson2k (Evgeny Grin) |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Lesser General Public | 7 | modify it under the terms of the GNU Lesser General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2.1 of the License, or (at your option) any later version. | 9 | version 2.1 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Lesser General Public License for more details. | 14 | Lesser General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Lesser General Public | 16 | You should have received a copy of the GNU Lesser General Public |
17 | License along with this library; if not, write to the Free Software | 17 | License along with this library; if not, write to the Free Software |
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file timeout.c | 21 | * @file timeout.c |
22 | * @brief example for how to use libmicrohttpd request timeout | 22 | * @brief example for how to use libmicrohttpd request timeout |
23 | * @author Christian Grothoff, Silvio Clecio (silvioprog), Karlson2k (Evgeny Grin) | 23 | * @author Christian Grothoff, Silvio Clecio (silvioprog), Karlson2k (Evgeny Grin) |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <microhttpd.h> | 26 | #include <microhttpd.h> |
27 | #include <stdio.h> | 27 | #include <stdio.h> |
28 | #include <string.h> | 28 | #include <string.h> |
29 | 29 | ||
30 | #define PORT 8080 | 30 | #define PORT 8080 |
31 | 31 | ||
32 | static int | 32 | static int |
33 | answer_to_connection(void *cls, | 33 | answer_to_connection(void *cls, |
34 | struct MHD_Connection *connection, | 34 | struct MHD_Connection *connection, |
35 | const char *url, | 35 | const char *url, |
36 | const char *method, | 36 | const char *method, |
37 | const char *version, | 37 | const char *version, |
38 | const char *upload_data, | 38 | const char *upload_data, |
39 | size_t *upload_data_size, | 39 | size_t *upload_data_size, |
40 | void **con_cls) | 40 | void **con_cls) |
41 | { | 41 | { |
42 | const char *page = "<html><body>Hello timeout!</body></html>"; | 42 | const char *page = "<html><body>Hello timeout!</body></html>"; |
43 | struct MHD_Response *response; | 43 | struct MHD_Response *response; |
44 | int ret; | 44 | int ret; |
45 | 45 | ||
46 | response = MHD_create_response_from_buffer (strlen(page), | 46 | response = MHD_create_response_from_buffer (strlen(page), |
47 | (void *) page, | 47 | (void *) page, |
48 | MHD_RESPMEM_PERSISTENT); | 48 | MHD_RESPMEM_PERSISTENT); |
49 | MHD_add_response_header (response, | 49 | MHD_add_response_header (response, |
50 | MHD_HTTP_HEADER_CONTENT_TYPE, | 50 | MHD_HTTP_HEADER_CONTENT_TYPE, |
51 | "text/html"); | 51 | "text/html"); |
52 | ret = MHD_queue_response (connection, | 52 | ret = MHD_queue_response (connection, |
53 | MHD_HTTP_OK, | 53 | MHD_HTTP_OK, |
54 | response); | 54 | response); |
55 | MHD_destroy_response(response); | 55 | MHD_destroy_response(response); |
56 | return ret; | 56 | return ret; |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | int | 60 | int |
61 | main (int argc, | 61 | main (int argc, |
62 | char **argv) | 62 | char **argv) |
63 | { | 63 | { |
64 | struct MHD_Daemon *daemon; | 64 | struct MHD_Daemon *daemon; |
65 | 65 | ||
66 | daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, | 66 | daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD, |
67 | PORT, | 67 | PORT, |
68 | NULL, NULL, | 68 | NULL, NULL, |
69 | &answer_to_connection, NULL, | 69 | &answer_to_connection, NULL, |
70 | /* 3 seconds */ | 70 | /* 3 seconds */ |
71 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 3, | 71 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 3, |
72 | MHD_OPTION_END); | 72 | MHD_OPTION_END); |
73 | if (NULL == daemon) | 73 | if (NULL == daemon) |
74 | return 1; | 74 | return 1; |
75 | getchar(); | 75 | getchar(); |
76 | MHD_stop_daemon(daemon); | 76 | MHD_stop_daemon(daemon); |
77 | return 0; | 77 | return 0; |
78 | } | 78 | } |