[PR #700] [CLOSED] fix: avoid directory listing work for plain HEAD requests #4098

Closed
opened 2026-05-26 23:07:52 +03:00 by zhus · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/sigoden/dufs/pull/700
Author: @jgoedeke
Created: 4/27/2026
Status: Closed

Base: mainHead: main


📝 Commits (2)

  • 8ef1df2 fix: skip plain directory listing on HEAD requests
  • a193cb0 fix: preserve plain HEAD handling for noscript clients

📊 Changes

2 files changed (+21 additions, -2 deletions)

View changed files

📝 src/server.rs (+17 -1)
📝 tests/http.rs (+4 -1)

📄 Description

Supersedes #687.

Today, a plain directory HEAD still goes through almost the full directory-listing path and only skips the body at the end. That means HEAD can still pay nearly the same backend cost as GET, even when the caller only wants headers / an existence check. In practice, HEAD can be used as a lightweight directory-existence probe, where only the response status and headers matter.

On slow or remote storage, that difference is noticeable. In my Samba-backed setup, a HEAD request to a 470-entry directory takes about 49.7s before this change and about 0.14s after it:

# before
$ time curl -I http://localhost:5000/large/or/slow/directory/
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
content-length: 58977
cache-control: no-cache
x-content-type-options: nosniff

curl -I  49.673 total

# after
$ time curl -I http://localhost:5000/large/or/slow/directory/
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
cache-control: no-cache
x-content-type-options: nosniff

curl -I  0.142 total

The previous PR missed one detail: curl-like clients are detected as noscript, so plain directory HEAD could still fall back to the listing path. This version limits noscript detection to GET, which preserves existing GET behavior and lets plain directory HEAD return early.

No new API is added, and this does not change directory GET, ?json, or WebDAV behavior.

References:


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/sigoden/dufs/pull/700 **Author:** [@jgoedeke](https://github.com/jgoedeke) **Created:** 4/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`8ef1df2`](https://github.com/sigoden/dufs/commit/8ef1df223e6f61b146cc9532dd5b323aded3b5b6) fix: skip plain directory listing on HEAD requests - [`a193cb0`](https://github.com/sigoden/dufs/commit/a193cb02d372a0e9bbc7c4bf5ad2db5e86e8b1f8) fix: preserve plain HEAD handling for noscript clients ### 📊 Changes **2 files changed** (+21 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/server.rs` (+17 -1) 📝 `tests/http.rs` (+4 -1) </details> ### 📄 Description Supersedes #687. Today, a plain directory `HEAD` still goes through almost the full directory-listing path and only skips the body at the end. That means `HEAD` can still pay nearly the same backend cost as `GET`, even when the caller only wants headers / an existence check. In practice, `HEAD` can be used as a lightweight directory-existence probe, where only the response status and headers matter. On slow or remote storage, that difference is noticeable. In my Samba-backed setup, a `HEAD` request to a 470-entry directory takes about **49.7s** before this change and about **0.14s** after it: ```sh # before $ time curl -I http://localhost:5000/large/or/slow/directory/ HTTP/1.1 200 OK content-type: text/html; charset=utf-8 content-length: 58977 cache-control: no-cache x-content-type-options: nosniff curl -I 49.673 total # after $ time curl -I http://localhost:5000/large/or/slow/directory/ HTTP/1.1 200 OK content-type: text/html; charset=utf-8 cache-control: no-cache x-content-type-options: nosniff curl -I 0.142 total ``` The previous PR missed one detail: curl-like clients are detected as noscript, so plain directory HEAD could still fall back to the listing path. This version limits noscript detection to GET, which preserves existing GET behavior and lets plain directory HEAD return early. No new API is added, and this does not change directory GET, ?json, or WebDAV behavior. References: - supersedes #687 - related context: #682 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
zhus added the pull-request label 2026-05-26 23:07:52 +03:00
zhus closed this issue 2026-05-26 23:07:53 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#4098