Roxen.git / server / protocols / http.pike

version» Context lines:

Roxen.git/server/protocols/http.pike:984:    "event" : "GOT_HEADERS",    "headers" : request_headers,    "prot" : prot,    "data_length" : strlen(data),    ]));       TIMER_START(parse_got_2_parse_headers);    array(int|string) new_forwarded_header = ({});    foreach (request_headers; string linename; array|string contents)    { -  if( arrayp(contents) ) contents = contents[0]; +  array(string) acontents; +  if( arrayp(contents) ) { +  acontents = contents; +  contents = contents[0]; +  } else { +  acontents = ({ contents }); +  }    switch (linename)    {    case "cache-control": // Opera sends "no-cache" here.    case "pragma": pragma|=(multiset)((contents-" ")/","); break;       case "content-length": misc->len = (int)contents; break;    case "transfer-encoding":    misc->transfer_encoding =    map(lower_case(contents)/";", String.trim_all_whites);    if (has_value(misc->transfer_encoding, "chunked")) {
Roxen.git/server/protocols/http.pike:1109:   #else    REQUEST_WERR(sprintf("HTTP: Send %O", res));   #endif    my_fd->write (res);    return 2;    }    break;       case "forwarded":    // RFC 7239 -  if (stringp(contents)) { -  misc->forwarded = MIME.tokenize(contents) / ({ ',' }); -  } else { -  misc->forwarded = map(map(contents, MIME.tokenize), `/, ({ ',' })) * -  ({}); -  } +  misc->forwarded = map(map(acontents, MIME.tokenize), `/, ({ ',' })) * ({});    break;       // The X-Forwarded-* headers have been obsoleted by RFC 7239.    // Convert them to the corresponding forwarded header as per    // RFC 7239 7.4. But only if it hasn't already been done.    case "x-forwarded-for":    if (request_headers->forwarded) break; -  foreach(stringp(contents)?({ contents }):contents, string line) { +  foreach(acontents, string line) {    foreach(MIME.tokenize(line) / ({ ',' }), array(string|int) segment) {    string ip;    if ((sizeof(segment) == 1) && stringp(segment[0])) {    ip = segment[0];    } else {    ip = MIME.quote(segment);    }    if (has_value(ip, ":") && !has_value(ip, ".") &&    !has_prefix(ip, "[")) {    // DWIM IPv6
Roxen.git/server/protocols/http.pike:1147:    }    new_forwarded_header += ({ "for", '=', ip });    }    }    break;    case "x-forwarded-by":    case "x-forwarded-host":    case "x-forwarded-proto":    if (request_headers->forwarded) break;    string field = linename[sizeof("x-forwarded-")..]; -  foreach(stringp(contents)?({ contents }):contents, string line) { +  foreach(acontents, string line) {    foreach(MIME.tokenize(line) / ({ ',' }), array(string|int) segment) {    string value;    if ((sizeof(segment) == 1) && stringp(segment[0])) {    value = segment[0];    } else {    value = MIME.quote(segment);    }    if (sizeof(new_forwarded_header)) {    new_forwarded_header += ({ ',' });    }