[Mono-bugs] [Bug 323215] HttpListener: 'Content-Length' is optional in request header
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Sep 28 03:39:23 EDT 2007
https://bugzilla.novell.com/show_bug.cgi?id=323215#c1
Marek Habersack <mhabersack at novell.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mhabersack at novell.com
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #1 from Marek Habersack <mhabersack at novell.com> 2007-09-28 01:39:22 MST ---
Using the sample at
http://msdn2.microsoft.com/en-us/library/system.net.httplistener.aspx
it seems that Mono's HttpListener behaves the same way what the MS.NET one.
Both implementations require content-length to be set on the PUT and POST
requests:
========= CUT HERE =========
PUT / HTTP/1.1
Host: localhost
HTTP/1.1 411 Length Required
Content-Type: text/html
Server: Microsoft-HTTPAPI/1.0
Date: Fri, 28 Sep 2007 07:16:01 GMT
Connection: close
Content-Length: 24
<h1>Length Required</h1>
----------------------------------------------
POST / HTTP/1.1
Host: localhost:8080
HTTP/1.1 411 Length Required
Content-Type: text/html
Server: Microsoft-HTTPAPI/1.0
Date: Fri, 28 Sep 2007 07:26:07 GMT
Connection: close
Content-Length: 24
<h1>Length Required</h1>
========= CUT HERE ========
According to RFC2616
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4) the above is a
correct behavior and the client, on receiving the 411 status, should resend the
message with the Content-Length header set (even if its value is 0, which
should happen in the case of the MindTouch Dream bug you are referring). Here's
the relevant fragment from the RFC:
"For compatibility with HTTP/1.0 applications, HTTP/1.1 requests containing a
message-body MUST include a valid Content-Length header field unless the server
is known to be HTTP/1.1 compliant. If a request contains a message-body and a
Content-Length is not given, the server SHOULD respond with 400 (bad request)
if it cannot determine the length of the message, or with 411 (length required)
if it wishes to insist on receiving a valid Content-Length."
In effect, it means that the Content-Length header should always be present,
since the clients rather shouldn't assume HTTP/1.1 server compatibility (unless
they issue a HEAD request prior to any other and trust the response).
Therefore, I'm closing this bug as the behavior Mono HttpListener exposes is
the same as MS.NET's, and valid according to the RFC.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list