https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782014-06-10T19:19:57ZRuby Issue Tracking SystemRuby master - Bug #9927: webrick does not unset content-length when responding to HEAD requestshttps://bugs.ruby-lang.org/issues/9927?journal_id=471502014-06-10T19:19:57Zadrienthebo (Adrien Thebo)adrien@somethingsinistral.net
<ul></ul><p>I didn't make this very clear, but the <code>curl</code> invocation hangs for about 6 seconds until the webrick server is killed, and then prints '<code>transfer closed with 23 bytes remaining to read</code>' which indicates it was hanging.</p> Ruby master - Bug #9927: webrick does not unset content-length when responding to HEAD requestshttps://bugs.ruby-lang.org/issues/9927?journal_id=471532014-06-10T19:58:32Zdrbrain (Eric Hodel)drbrain@segment7.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Rejected</i></li></ul><p>This appears to be a bug in curl.</p>
<p>RFC 7230 says:</p>
<pre><code>3.3. Message Body
The message body (if any) of an HTTP message is used to carry the
payload body of that request or response. The message body is
identical to the payload body unless a transfer coding has been
applied, as described in Section 3.3.1.
message-body = *OCTET
The rules for when a message body is allowed in a message differ for
requests and responses.
The presence of a message body in a request is signaled by a
Content-Length or Transfer-Encoding header field. Request message
framing is independent of method semantics, even if the method does
not define any use for a message body.
The presence of a message body in a response depends on both the
request method to which it is responding and the response status code
(Section 3.1.2). Responses to the HEAD request method (Section 4.3.2
of [RFC7231]) never include a message body because the associated
response header fields (e.g., Transfer-Encoding, Content-Length,
etc.), if present, indicate only what their values would have been if
the request method had been GET (Section 4.3.1 of [RFC7231]). 2xx
(Successful) responses to a CONNECT request method (Section 4.3.6 of
[RFC7231]) switch to tunnel mode instead of having a message body.
All 1xx (Informational), 204 (No Content), and 304 (Not Modified)
responses do not include a message body. All other responses do
include a message body, although the body might be of zero length.
</code></pre>
<p>RFC 2616 says the same using different words in 4.4:</p>
<pre><code> 1.Any response message which "MUST NOT" include a message-body (such
as the 1xx, 204, and 304 responses and any response to a HEAD
request) is always terminated by the first empty line after the
header fields, regardless of the entity-header fields present in
the message.
</code></pre> Ruby master - Bug #9927: webrick does not unset content-length when responding to HEAD requestshttps://bugs.ruby-lang.org/issues/9927?journal_id=471542014-06-10T19:58:48Zphluid61 (Matthew Kerwin)matthew@kerwin.net.au
<ul></ul><p>Adrien Thebo wrote:</p>
<blockquote>
<p>I didn't make this very clear, but the <code>curl</code> invocation hangs for about 6 seconds until the webrick server is killed, and then prints '<code>transfer closed with 23 bytes remaining to read</code>' which indicates it was hanging.</p>
</blockquote>
<p>This is a problem with the way you're using curl. Webrick is doing the right thing according to the HTTP spec[1], which states that "the payload header fields [including content-length] MAY be omitted." There is no obligation on the server to do so.</p>
<p>You have to tell your client (curl) not to wait for a message body. -X HEAD just changes bytes omitted in the request, but doesn't change the client behaviour; you have to use -I to signal that this is a metadata-only fetch [2]</p>
<p>[1] <a href="http://tools.ietf.org/html/rfc7231#section-4.3.2" class="external">http://tools.ietf.org/html/rfc7231#section-4.3.2</a><br>
[2] <a href="http://linux.die.net/man/1/curl" class="external">http://linux.die.net/man/1/curl</a></p> Ruby master - Bug #9927: webrick does not unset content-length when responding to HEAD requestshttps://bugs.ruby-lang.org/issues/9927?journal_id=471552014-06-10T20:18:32Zadrienthebo (Adrien Thebo)adrien@somethingsinistral.net
<ul></ul><p>My error, sorry for the distraction.</p> Ruby master - Bug #9927: webrick does not unset content-length when responding to HEAD requestshttps://bugs.ruby-lang.org/issues/9927?journal_id=474232014-06-27T22:55:12Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Has duplicate</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/9986">Bug #9986</a>: WEBrick content-length being set when transfer-encoding is chunked</i> added</li></ul> Ruby master - Bug #9927: webrick does not unset content-length when responding to HEAD requestshttps://bugs.ruby-lang.org/issues/9927?journal_id=474652014-06-30T08:00:27Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Has duplicate</strong> deleted (<i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/9986">Bug #9986</a>: WEBrick content-length being set when transfer-encoding is chunked</i>)</li></ul>