Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

2006-05-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>

	* ResponseStream.cs:
	* HttpListenerResponse.cs: allow 0 length POST. Patch by Horst Reiterer.
	Closes bug #78316.


svn path=/branches/mono-1-1-13/mcs/; revision=60366
  • Loading branch information...
commit b71dfbe5bf0430129a4e3b5c0e001e1b8b2e3f24 1 parent 54775ae
@gonzalop gonzalop authored
View
6 mcs/class/System/System.Net/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-06 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * ResponseStream.cs:
+ * HttpListenerResponse.cs: allow 0 length POST. Patch by Horst Reiterer.
+ Closes bug #78316.
+
2006-04-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* WebConnection.cs: reset the challenge and the status code when
View
16 mcs/class/System/System.Net/HttpListenerResponse.cs
@@ -393,7 +393,7 @@ bool FindCookie (Cookie cookie)
return false;
}
- internal void SendHeaders ()
+ internal void SendHeaders (bool closing)
{
//TODO: When do we send KeepAlive?
//TODO: send cookies
@@ -418,8 +418,15 @@ internal void SendHeaders ()
if (headers ["Date"] == null)
headers.SetInternal ("Date", DateTime.UtcNow.ToString ("r", inv));
- if (!chunked && cl_set)
- headers.SetInternal ("Content-Length", content_length.ToString (inv));
+ if (!chunked) {
+ if (!cl_set && closing) {
+ cl_set = true;
+ content_length = 0;
+ }
+
+ if (cl_set)
+ headers.SetInternal ("Content-Length", content_length.ToString (inv));
+ }
Version v = context.Request.ProtocolVersion;
if (!cl_set && !chunked && v >= HttpVersion.Version11)
@@ -465,6 +472,9 @@ internal void SendHeaders ()
writer.Flush ();
// Perf.: use TCP_CORK if we're writing more?
int preamble = encoding.GetPreamble ().Length;
+ if (output_stream == null)
+ output_stream = context.Connection.GetResponseStream ();
+
output_stream.InternalWrite (ms.GetBuffer (), 0 + preamble, (int) ms.Length - preamble);
HeadersSent = true;
}
View
7 mcs/class/System/System.Net/ResponseStream.cs
@@ -74,6 +74,9 @@ public override void Close ()
{
if (disposed == false) {
disposed = true;
+ if (response.HeadersSent == false)
+ response.SendHeaders (true);
+
if (response.SendChunked && !trailer_sent) {
WriteChunkSize (0, true);
trailer_sent = true;
@@ -111,7 +114,7 @@ public override void Write (byte [] buffer, int offset, int count)
throw new ObjectDisposedException (GetType ().ToString ());
if (response.HeadersSent == false)
- response.SendHeaders ();
+ response.SendHeaders (false);
bool chunked = response.SendChunked;
try {
@@ -132,7 +135,7 @@ public override void Write (byte [] buffer, int offset, int count)
throw new ObjectDisposedException (GetType ().ToString ());
if (response.HeadersSent == false)
- response.SendHeaders ();
+ response.SendHeaders (false);
try {
if (response.SendChunked)
Please sign in to comment.
Something went wrong with that request. Please try again.