Mercurial > urweb
comparison src/c/urweb.c @ 1050:93315ac00394
More fun with cookies
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 26 Nov 2009 14:20:00 -0500 |
parents | a8a825861397 |
children | 731e6aa6655a |
comparison
equal
deleted
inserted
replaced
1049:c2317cfb99ec | 1050:93315ac00394 |
---|---|
670 | 670 |
671 return r; | 671 return r; |
672 } | 672 } |
673 | 673 |
674 int uw_set_input(uw_context ctx, const char *name, char *value) { | 674 int uw_set_input(uw_context ctx, const char *name, char *value) { |
675 printf("Input name %s\n", name); | 675 //printf("Input name %s\n", name); |
676 | 676 |
677 if (!strcasecmp(name, ".b")) { | 677 if (!strcasecmp(name, ".b")) { |
678 int n = uw_input_num(value); | 678 int n = uw_input_num(value); |
679 input *inps; | 679 input *inps; |
680 | 680 |
2678 } | 2678 } |
2679 | 2679 |
2680 return NULL; | 2680 return NULL; |
2681 } | 2681 } |
2682 | 2682 |
2683 uw_unit uw_Basis_set_cookie(uw_context ctx, uw_Basis_string prefix, uw_Basis_string c, uw_Basis_string v) { | 2683 uw_unit uw_Basis_set_cookie(uw_context ctx, uw_Basis_string prefix, uw_Basis_string c, uw_Basis_string v, uw_Basis_time *expires, uw_Basis_bool secure) { |
2684 uw_write_header(ctx, "Set-Cookie: "); | 2684 uw_write_header(ctx, "Set-Cookie: "); |
2685 uw_write_header(ctx, c); | 2685 uw_write_header(ctx, c); |
2686 uw_write_header(ctx, "="); | 2686 uw_write_header(ctx, "="); |
2687 uw_write_header(ctx, v); | 2687 uw_write_header(ctx, v); |
2688 uw_write_header(ctx, "; path="); | 2688 uw_write_header(ctx, "; path="); |
2689 uw_write_header(ctx, prefix); | 2689 uw_write_header(ctx, prefix); |
2690 if (expires) { | |
2691 char formatted[30]; | |
2692 struct tm tm; | |
2693 | |
2694 gmtime_r(expires, &tm); | |
2695 | |
2696 strftime(formatted, sizeof formatted, "%a, %d-%b-%Y %T GMT", &tm); | |
2697 | |
2698 uw_write_header(ctx, "; expires="); | |
2699 uw_write_header(ctx, formatted); | |
2700 } | |
2701 if (secure) | |
2702 uw_write_header(ctx, "; secure"); | |
2690 uw_write_header(ctx, "\r\n"); | 2703 uw_write_header(ctx, "\r\n"); |
2704 | |
2705 return uw_unit_v; | |
2706 } | |
2707 | |
2708 uw_unit uw_Basis_clear_cookie(uw_context ctx, uw_Basis_string prefix, uw_Basis_string c) { | |
2709 uw_write_header(ctx, "Set-Cookie: "); | |
2710 uw_write_header(ctx, c); | |
2711 uw_write_header(ctx, "=; path="); | |
2712 uw_write_header(ctx, prefix); | |
2713 uw_write_header(ctx, "; expires=Mon, 01-01-1970 00:00:00 GMT\r\n"); | |
2691 | 2714 |
2692 return uw_unit_v; | 2715 return uw_unit_v; |
2693 } | 2716 } |
2694 | 2717 |
2695 static delta *allocate_delta(uw_context ctx, unsigned client) { | 2718 static delta *allocate_delta(uw_context ctx, unsigned client) { |
3075 *s2 = 0; | 3098 *s2 = 0; |
3076 | 3099 |
3077 return r; | 3100 return r; |
3078 } | 3101 } |
3079 | 3102 |
3103 const uw_Basis_time minTime = 0; | |
3104 | |
3080 uw_Basis_time uw_Basis_now(uw_context ctx) { | 3105 uw_Basis_time uw_Basis_now(uw_context ctx) { |
3081 return time(NULL); | 3106 return time(NULL); |
3082 } | 3107 } |