diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-08 19:35:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-08 19:35:27 +0000 |
commit | 39f06e27b72254c63d3ed9741efd3b528cc09e99 (patch) | |
tree | 979c19ce3ad7336418072b7107199531baf2e47e /doc | |
parent | 0bfe068c101ea5848950ed9fe4d4d32bd2a3f7f4 (diff) | |
download | libmicrohttpd-39f06e27b72254c63d3ed9741efd3b528cc09e99.tar.gz libmicrohttpd-39f06e27b72254c63d3ed9741efd3b528cc09e99.zip |
fix FIXME in tutorial
Diffstat (limited to 'doc')
-rw-r--r-- | doc/chapters/sessions.inc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/doc/chapters/sessions.inc b/doc/chapters/sessions.inc index e4ee91d4..ee48e58e 100644 --- a/doc/chapters/sessions.inc +++ b/doc/chapters/sessions.inc | |||
@@ -16,10 +16,14 @@ Since MHD parses the HTTP cookie header for us, looking up an existing cookie | |||
16 | is straightforward: | 16 | is straightforward: |
17 | 17 | ||
18 | @verbatim | 18 | @verbatim |
19 | FIXME. | 19 | const char *value; |
20 | |||
21 | value = MHD_lookup_connection_value (connection, | ||
22 | MHD_COOKIE_KIND, | ||
23 | "KEY"); | ||
20 | @end verbatim | 24 | @end verbatim |
21 | 25 | ||
22 | Here, FIXME is the name we chose for our session cookie. | 26 | Here, "KEY" is the name we chose for our session cookie. |
23 | 27 | ||
24 | 28 | ||
25 | @heading Setting the cookie header | 29 | @heading Setting the cookie header |
@@ -29,14 +33,27 @@ cookies. In order to generate a unique cookie, our example creates a random | |||
29 | 64-character text string to be used as the value of the cookie: | 33 | 64-character text string to be used as the value of the cookie: |
30 | 34 | ||
31 | @verbatim | 35 | @verbatim |
32 | FIXME. | 36 | char value[128]; |
37 | char raw_value[65]; | ||
38 | |||
39 | for (unsigned int i=0;i<sizeof (raw_value);i++) | ||
40 | raw_value = 'A' + (rand () % 26); /* bad PRNG! */ | ||
41 | raw_value[64] = '\0'; | ||
42 | snprintf (value, sizeof (value), | ||
43 | "%s=%s", | ||
44 | "KEY", | ||
45 | raw_value); | ||
33 | @end verbatim | 46 | @end verbatim |
34 | 47 | ||
35 | Given this cookie value, we can then set the cookie header in our HTTP response | 48 | Given this cookie value, we can then set the cookie header in our HTTP response |
36 | as follows: | 49 | as follows: |
37 | 50 | ||
38 | @verbatim | 51 | @verbatim |
39 | FIXME. | 52 | assert (MHD_YES == |
53 | MHD_set_connection_value (connection, | ||
54 | MHD_HEADER_KIND, | ||
55 | MHD_HTTP_HEADER_SET_COOKIE, | ||
56 | value)); | ||
40 | @end verbatim | 57 | @end verbatim |
41 | 58 | ||
42 | 59 | ||