[Mono-bugs] [Bug 510642] New: HttpWebRequest: No ProtoviolationException when writing beyond specified content-length

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Jun 5 17:05:34 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=510642


           Summary: HttpWebRequest: No ProtoviolationException when
                    writing beyond specified content-length
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR
3.0.04506.30; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR
3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

NET throws a ProtocolViolationException when you attempt to write more bytes
to the request stream than the specified ContentLength. We currently allow
this.

Reproducible: Always

Steps to Reproduce:
Compile and run the following code:

using System;
using System.IO;
using System.Net;

class Program
{
    static void Main ()
    {
        HttpWebRequest req = (HttpWebRequest) WebRequest.Create (new Uri
("http://mono-project.com"));
        req.Method = "POST";
        req.ContentLength = 2;

        byte [] buffer = new byte [] { 0x2a, 0x2c, 0x1d };

        Stream rs = req.GetRequestStream ();
        rs.Write (buffer, 0, 3);
    }
}

Actual Results:  
No exception.

Expected Results:  
Unhandled Exception: System.Net.ProtocolViolationException: Bytes to be written
to the stream exceed the Content-Length bytes size specified.
   at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer,
Int32
 offset, Int32 size, AsyncCallback callback, Object state)
   at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at Program.Main()

I'll add a test named "GetRequestStream_Write_Overflow" to
HttpWebRequestTest.cs, and mark it NotWorking.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list