Branch: Tag:

2018-04-03

2018-04-03 13:12:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Testsuite [WebDAV]: Improved if-header generation.

Use the tagged syntax for the if-header.

Fixes multiple precondition failed issues with recursive requests.

130:    headers["destination"] = (string)dest_uri;    }    +  string if_header = "";    multiset(string) locks = (<>);    if (current_locks) {    foreach(lock_paths, string dir) {    while(1) { -  string lock = current_locks[dir]; -  if (lock) { -  locks[lock] = 1; +  string lock_token = current_locks[dir]; +  if (lock_token && !locks[lock_token]) { +  string path = map((dir/"/"), Protocols.HTTP.percent_encode) * "/"; +  if (has_prefix(path, "/")) { +  path = path[1..];    } -  +  path = Standards.URI(path, base_uri)->path; +  if_header += sprintf("<%s>(<%s>)", path, lock_token); +  locks[lock_token] = 1; +  }    if (dir == "/") {    break;    }
149:    (lower_case(method) == "delete")) {    foreach(indices(current_locks), string path) {    foreach(lock_paths, string dir) { -  if (has_prefix(path, dir + "/")) { -  locks[current_locks[path]] = 1; +  string lock_token = current_locks[path]; +  if (has_prefix(path, dir + "/") && !locks[lock_token]) { +  if (has_prefix(path, "/")) { +  path = path[1..];    } -  +  path = map((path/"/"), Protocols.HTTP.percent_encode) * "/"; +  path = Standards.URI(path, base_uri)->path; +  if_header += sprintf("<%s>(<%s>)", path, lock_token); +  locks[lock_token] = 1;    }    }    } -  if (sizeof(locks)) { -  headers->if = "(<" + (indices(locks) * ">), (<") + ">)"; +     } -  +  if (sizeof(if_header)) { +  headers->if = if_header;    } -  +  }    if (has_prefix(path, "/")) {    path = path[1..];    }