Introduction
Introduction Statistics Contact Development Disclaimer Help
tvote.c: use 307 redirect to avoid additional voting through refresh - vote - s…
git clone git://src.adamsgaard.dk/vote
Log
Files
Refs
README
LICENSE
---
commit 6cf52771bc127fbf083ca9badeeac6dba89d65fb
parent 0b3501599120c01cca8c2e8532fcd31e781f48ec
Author: Anders Damsgaard <[email protected]>
Date: Mon, 28 Sep 2020 14:47:37 +0200
vote.c: use 307 redirect to avoid additional voting through refresh
Diffstat:
M vote.c | 32 ++++++++++++++++++++++-------…
1 file changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/vote.c b/vote.c
t@@ -25,6 +25,10 @@ void
http_status(int statuscode)
{
switch(statuscode) {
+ case 307:
+ printf("Status: 307 Temporary Redirect\r\n");
+ printf("Location: /vote?poll=%s&choice=0\r\n\r\n", poll);
+ break;
case 401:
printf("Status: 401 Bad Request\r\n\r\n");
break;
t@@ -402,28 +406,38 @@ main()
}
}
- print_html_head();
-
parse_query();
if (*create) {
- if (create_poll_file(poll, question, options) == 0)
+ if (create_poll_file(poll, question, options) == 0) {
+ print_html_head();
show_poll(poll, 0);
+ print_html_foot();
+ }
} else if (*poll) {
if (*choice) {
- c = strtonum(choice, 1, 256, &errstr);
+ c = strtonum(choice, 0, 256, &errstr);
if (errstr != NULL)
errx(1, "could not parse choice: %s, %s", errs…
- increment_option(poll, c);
- show_poll(poll, 0);
- } else
+ if (c > 0) {
+ increment_option(poll, c);
+ http_status(307);
+ } else {
+ print_html_head();
+ show_poll(poll, 0);
+ print_html_foot();
+ }
+ } else {
+ print_html_head();
show_poll(poll, 1);
+ print_html_foot();
+ }
} else {
+ print_html_head();
list_polls();
print_poll_create_form();
+ print_html_foot();
}
- print_html_foot();
-
return 0;
}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.