You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever a HEAD request is made, if it's routed to a GET handler, a tide server will reply with the correct headers but it'll also serve the full body.
Code/Gist
I don't have a small reproduction test case right now, but hopefully it should be pretty easy to verify that this happens. I'm curious why the test introduced in #179 doesn't catch it - maybe because it uses a test server, not the real thing?
Expected behavior/code
I would expect tide to serve the correct headers (including content-length), but not the body.
As things stand, I can't implement HEAD correctly, because either I let the GET handler do its thing, and tide sends the whole body, or I add a wrapper that runs the GET handler and overrides the body to be empty - but insert_header("content-length") is always overwritten later by tide itself, so that would be an invalid HEAD response.
Environment
tide version: 0.11.0
Rust toolchain version(s): 1.44.1
OS: Linux, Windows 10, any tbh
Possible Solution
I haven't looked too closely at the how responses are actually handled by tide, so I'm not sure.
Additional context/Screenshots
This is how curl behaves:
$ curl -X HEAD http://localhost:1111/ 2>&1| head -20
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0<!DOCTYPE html><html lang="en"><head><title>
fasterthanli.me
</title><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"><meta name="robots" content="noodp"/><link rel="stylesheet" href="/style.01ebxdp48thp88vghj60msqtx4.css"><link rel="shortcut icon" href="/img/logo-round.png">
For comparison, curl -X HEAD -v http://example.org shows the headers, then hangs - because curl expects the body to be there.
Note that curl's --head or -I options hide the problem. They never read the body, whether the server sends it or not.
The text was updated successfully, but these errors were encountered:
Bug Report
Current Behavior
Whenever a HEAD request is made, if it's routed to a GET handler, a tide server will reply with the correct headers but it'll also serve the full body.
Code/Gist
I don't have a small reproduction test case right now, but hopefully it should be pretty easy to verify that this happens. I'm curious why the test introduced in #179 doesn't catch it - maybe because it uses a test server, not the real thing?
Expected behavior/code
I would expect tide to serve the correct headers (including
content-length
), but not the body.As things stand, I can't implement HEAD correctly, because either I let the GET handler do its thing, and tide sends the whole body, or I add a wrapper that runs the GET handler and overrides the body to be empty - but
insert_header("content-length")
is always overwritten later by tide itself, so that would be an invalid HEAD response.Environment
Possible Solution
I haven't looked too closely at the how responses are actually handled by tide, so I'm not sure.
Additional context/Screenshots
This is how curl behaves:
For comparison,
curl -X HEAD -v http://example.org
shows the headers, then hangs - because curl expects the body to be there.Note that curl's
--head
or-I
options hide the problem. They never read the body, whether the server sends it or not.The text was updated successfully, but these errors were encountered: