View | Details | Raw Unified | Return to bug 63434
Collapse All | Expand All

(-)a/server/protocol.c (-5 / +52 lines)
Lines 989-994 static int table_do_fn_check_lengths(void *r_, const char *key, Link Here
989
    return 0;
989
    return 0;
990
}
990
}
991
991
992
typedef struct {
993
  apr_pool_t *p;
994
  const char *first;
995
  apr_array_header_t *merged;
996
  int entries;
997
} cookie_hdrs_state;
998
999
static int table_do_fn_collect_cookies(void *v, const char *key,
1000
                                       const char *value) {
1001
  cookie_hdrs_state *state = (cookie_hdrs_state *)v;
1002
  const char **elt;
1003
1004
  if (!state->first) {
1005
    /* fast path for common case (only one Cookie header) that doesn't allocate
1006
     * any memory */
1007
    state->first = value;
1008
    return 1;
1009
  }
1010
1011
  if (!state->merged) {
1012
    state->merged = apr_array_make(state->p, 10, sizeof(const char *));
1013
    /* push first found value */
1014
    elt = apr_array_push(state->merged);
1015
    *elt = state->first;
1016
    state->entries++;
1017
  }
1018
  elt = apr_array_push(state->merged);
1019
  *elt = value;
1020
  state->entries++;
1021
1022
  return 1;
1023
}
1024
992
AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb)
1025
AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb)
993
{
1026
{
994
    char *last_field = NULL;
1027
    char *last_field = NULL;
Lines 1239-1248 AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb Link Here
1239
        last_len = len;
1272
        last_len = len;
1240
    }
1273
    }
1241
1274
1242
    /* Combine multiple message-header fields with the same
1275
    {
1243
     * field-name, following RFC 2616, 4.2.
1276
      cookie_hdrs_state state = {r->pool, NULL, 0};
1244
     */
1277
1245
    apr_table_compress(r->headers_in, APR_OVERLAP_TABLES_MERGE);
1278
      /* prepare for the case if there are multiple Cookie headers */
1279
      apr_table_do(table_do_fn_collect_cookies, &state, r->headers_in,
1280
                   "Cookie", NULL);
1281
1282
      /* Combine multiple message-header fields with the same
1283
       * field-name, following RFC 2616, 4.2.
1284
       */
1285
      apr_table_compress(r->headers_in, APR_OVERLAP_TABLES_MERGE);
1286
1287
      if (state.entries > 1) {
1288
        /* replace compressed Cookie header value by string consisting of
1289
         * semicolon-separated cookie-pairs */
1290
        apr_table_set(r->headers_in, "Cookie",
1291
                      apr_array_pstrcat(r->pool, state.merged, ';'));
1292
      }
1293
    }
1246
1294
1247
    /* enforce LimitRequestFieldSize for merged headers */
1295
    /* enforce LimitRequestFieldSize for merged headers */
1248
    apr_table_do(table_do_fn_check_lengths, r, r->headers_in, NULL);
1296
    apr_table_do(table_do_fn_check_lengths, r, r->headers_in, NULL);
1249
- 

Return to bug 63434