MCPcopy Create free account
hub / github.com/apache/httpd / add_cookie

Function add_cookie

modules/mappers/mod_rewrite.c:2728–2828  ·  view source on GitHub ↗

* perform all the expansions on the cookies * * TODO: use cached time similar to how logging does it */

Source from the content-addressed store, hash-verified

2726 * TODO: use cached time similar to how logging does it
2727 */
2728static void add_cookie(request_rec *r, char *s)
2729{
2730 char *var;
2731 char *val;
2732 char *domain;
2733 char *expires;
2734 char *path;
2735 char *secure;
2736 char *httponly;
2737 char *samesite;
2738
2739 char *tok_cntx;
2740 char *cookie;
2741 /* long-standing default, but can't use ':' in a cookie */
2742 const char *sep = ":";
2743
2744 /* opt-in to ; separator if first character is a ; */
2745 if (s && *s == ';') {
2746 sep = ";";
2747 s++;
2748 }
2749
2750 var = apr_strtok(s, sep, &tok_cntx);
2751 val = apr_strtok(NULL, sep, &tok_cntx);
2752 domain = apr_strtok(NULL, sep, &tok_cntx);
2753
2754 if (var && val && domain) {
2755 request_rec *rmain = r;
2756 char *notename;
2757 void *data;
2758
2759 while (rmain->main) {
2760 rmain = rmain->main;
2761 }
2762
2763 notename = apr_pstrcat(rmain->pool, var, "_rewrite", NULL);
2764 apr_pool_userdata_get(&data, notename, rmain->pool);
2765 if (!data) {
2766 char *exp_time = NULL;
2767
2768 expires = apr_strtok(NULL, sep, &tok_cntx);
2769 path = expires ? apr_strtok(NULL, sep, &tok_cntx) : NULL;
2770 secure = path ? apr_strtok(NULL, sep, &tok_cntx) : NULL;
2771 httponly = secure ? apr_strtok(NULL, sep, &tok_cntx) : NULL;
2772 samesite = httponly ? apr_strtok(NULL, sep, &tok_cntx) : NULL;
2773
2774 if (expires) {
2775 apr_time_exp_t tms;
2776 long exp_min;
2777
2778 exp_min = atol(expires);
2779 if (exp_min) {
2780 apr_time_exp_gmt(&tms, r->request_time
2781 + apr_time_from_sec((60 * exp_min)));
2782 exp_time = apr_psprintf(r->pool, "%s, %.2d-%s-%.4d "
2783 "%.2d:%.2d:%.2d GMT",
2784 apr_day_snames[tms.tm_wday],
2785 tms.tm_mday,

Callers 1

do_expand_cookieFunction · 0.85

Calls 1

ap_cstr_casecmpFunction · 0.85

Tested by

no test coverage detected