508 Loop Detected는 서버가 요청을 처리하는 도중 무한 루프를 발견했다는 뜻입니다. WebDAV에서 바인딩(binding, 심볼릭 링크와 유사)이 서로를 순환 참조하는 구조를 깊이 탐색(Depth: infinity)하다가 끝없이 반복될 때 반환됩니다.
서버는 리소스를 무한히 순회하는 대신, 루프를 감지하고 508로 요청을 중단합니다. 자원을 무한히 소모하는 것을 막기 위한 안전장치입니다.
PROPFIND /a/ HTTP/1.1
Host: dav.example.com
Depth: infinity
(a and b are bindings that reference each other)HTTP/1.1 508 Loop Detected
Content-Type: application/xml
<D:error xmlns:D="DAV:"><D:no-external-entities/></D:error>// Track visited nodes so a cyclic binding structure aborts as 508
const seen = new Set();
function walk(node, res) {
if (seen.has(node.id)) { res.status(508); throw new Error('loop'); }
seen.add(node.id);
node.children.forEach(c => walk(c, res));
}