aboutsummaryrefslogtreecommitdiff
path: root/src/examples/refuse_post_example.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/refuse_post_example.c')
-rw-r--r--src/examples/refuse_post_example.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/examples/refuse_post_example.c b/src/examples/refuse_post_example.c
index 5a2b1eb1..5c229e14 100644
--- a/src/examples/refuse_post_example.c
+++ b/src/examples/refuse_post_example.c
@@ -24,7 +24,7 @@
24#include "platform.h" 24#include "platform.h"
25#include <microhttpd.h> 25#include <microhttpd.h>
26 26
27const char* askpage = "<html><body>\n\ 27const char *askpage = "<html><body>\n\
28 Upload a file, please!<br>\n\ 28 Upload a file, please!<br>\n\
29 <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\ 29 <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\
30 <input name=\"file\" type=\"file\">\n\ 30 <input name=\"file\" type=\"file\">\n\
@@ -48,20 +48,23 @@ ahc_echo (void *cls,
48 48
49 if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST"))) 49 if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST")))
50 return MHD_NO; /* unexpected method */ 50 return MHD_NO; /* unexpected method */
51 51
52 if (&aptr != *ptr) 52 if (&aptr != *ptr)
53 { 53 {
54 *ptr = &aptr; 54 *ptr = &aptr;
55 55
56 /* always to busy for POST requests */ 56 /* always to busy for POST requests */
57 if (0 == strcmp (method, "POST")) 57 if (0 == strcmp (method, "POST"))
58 { 58 {
59 response = MHD_create_response_from_data (strlen (BUSYPAGE), 59 response = MHD_create_response_from_data (strlen (BUSYPAGE),
60 (void *) BUSYPAGE, MHD_NO, MHD_NO); 60 (void *) BUSYPAGE, MHD_NO,
61 ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); 61 MHD_NO);
62 MHD_destroy_response (response); 62 ret =
63 return ret; 63 MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE,
64 } 64 response);
65 MHD_destroy_response (response);
66 return ret;
67 }
65 } 68 }
66 69
67 *ptr = NULL; /* reset when done */ 70 *ptr = NULL; /* reset when done */
@@ -84,7 +87,8 @@ main (int argc, char *const *argv)
84 } 87 }
85 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 88 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG,
86 atoi (argv[1]), 89 atoi (argv[1]),
87 NULL, NULL, &ahc_echo, (void *) askpage, MHD_OPTION_END); 90 NULL, NULL, &ahc_echo, (void *) askpage,
91 MHD_OPTION_END);
88 if (d == NULL) 92 if (d == NULL)
89 return 1; 93 return 1;
90 sleep (atoi (argv[2])); 94 sleep (atoi (argv[2]));