Skip to content

Conversation

@gogalvijay
Copy link

Previously, directory redirects (e.g., requesting /path without a trailing slash) sent a 301 Moved Permanently response consisting only of headers. This caused clients that expect a response body or connection closure (such as curl or strict HTTP/1.0 clients) to hang indefinitely waiting for content.

This patch adds a minimal HTML body to the 301 response, compliant with RFC 2616. This ensures clients can correctly detect the end of the message and close the connection immediately.

Testing:
Verified using curl and pro inside SerenityOS.

  1. Created a test directory: mkdir /var/www/test_redirect
  2. Requested without trailing slash: curl -v http://127.0.0.1:8000/test_redirect
  3. Confirmed the request completes immediately and prints the HTML body.

Fixes the issue where 301 redirects served by the WebServer get stuck.

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Dec 12, 2025
@BuggieBot
Copy link
Member

Hello!

One or more of the commit messages in this PR do not match the SerenityOS code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why.
Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.

Previously, directory redirects sent a 301 response without a body,
causing clients like curl to hang. This patch adds a minimal HTML
body to the response, allowing clients to correctly detect the end
of the message.
@gogalvijay gogalvijay force-pushed the WebServer/fix-301-redirect-body branch from 19de890 to 89a54ac Compare December 12, 2025 20:45
@LucasChollet
Copy link
Member

It doesn't seem like we need to send a body with the redirect. Using python's python -m http.server I got this result with curl:

< HTTP/1.0 301 Moved Permanently
< Server: SimpleHTTP/0.6 Python/3.13.7
< Date: Wed, 24 Dec 2025 16:38:05 GMT
< Location: /Downloads/
< Content-Length: 0
< 
* shutting down connection #0

@LucasChollet
Copy link
Member

Also, this is related to #26431. (if you add Fixes #ISSUE_NUMBER to the PR description, it will automatically close the issue when the PR is merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants