[Mono-bugs] [Bug 43362][Maj] Changed - multipart form data bug

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Fri, 23 May 2003 03:18:13 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by mark_kuschnir@yahoo.co.uk.

http://bugzilla.ximian.com/show_bug.cgi?id=43362

--- shadow/43362	Wed May 21 12:05:04 2003
+++ shadow/43362.tmp.22533	Fri May 23 03:18:13 2003
@@ -1,12 +1,12 @@
 Bug#: 43362
 Product: Mono/Class Libraries
 Version: unspecified
 OS: unknown
 OS Details: Windows 2000 with all service packs
-Status: NEEDINFO   
+Status: REOPENED   
 Resolution: 
 Severity: Unknown
 Priority: Major
 Component: System.Web
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: Mark_Kuschnir@yahoo.co.uk               
@@ -343,6 +343,207 @@
 Please submit an example that is:
 1) Smaller
 2) Not dependant on having your custom website
 
 It would be fine if you were to have an aspx page that acted as a 
 mini-replica of your database.
+
+------- Additional Comments From Mark_Kuschnir@yahoo.co.uk  2003-05-23 03:18 -------
+Slightly shorter code follows. You don't even need an instance of the 
+database. As the code shows putting HttpSniffer on localhost:8000 was 
+sufficient to show the incomplete message.
+
+using System;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Xml;
+using System.Collections.Specialized;
+
+/// <summary>
+/// Implement an HTTP POST request.
+/// </summary>
+
+internal class HttpPostRequest
+{
+	/// <summary>
+	/// The boundary constant for the multipart/form-data HTTP 
+requests.
+	/// </summary>
+	const string BOUNDARY = "---------------------------
+7d16151062e";
+	
+	/// <summary>
+	/// The start boundary constant for the multipart/form-data 
+HTTP requests.
+	/// </summary>
+	const string START_BOUNDARY = "--" + BOUNDARY;
+	
+	/// <summary>
+	/// The end boundary constant for the multipart/form-data 
+HTTP requests.
+	/// </summary>
+	const string END_BOUNDARY = START_BOUNDARY + "--";
+	
+	/// <summary>
+	/// The line separator constant, which is for multipart/form-
+data CRLF.
+	/// </summary>
+	const string LINE_SEPARATOR = "\r\n";
+
+	/// <summary>
+	/// HTTP request.
+	/// </summary>
+	HttpWebRequest m_req;
+
+	/// <summary>
+	/// Request output stream.
+	/// </summary>
+	StreamWriter m_writer;
+        		
+	//============================================================
+========
+	/// <summary>
+	/// Construct a request object tied to the specified url.
+	/// </summary>
+	///	<param name="url">url the request is for</param>
+		
+	internal HttpPostRequest(string url)
+	{
+		m_req = (HttpWebRequest) WebRequest.Create(url);
+		m_req.Method = "POST";
+		m_req.Headers["Accept-Charset"] = "utf-8";
+		m_req.UserAgent = "InsertTest";
+		m_req.ContentType = "multipart/form-data; boundary=" 
++ BOUNDARY;
+
+		m_writer = new StreamWriter(m_req.GetRequestStream());
+	}
+					
+	//============================================================
+========
+	/// <summary>
+	/// Write the specified name/value pair.
+	/// </summary>
+	/// <param name="name">data name</param>
+	/// <param name="val">data value</param>
+		
+	internal void Write(string name, string val)
+	{
+		m_writer.Write(START_BOUNDARY);
+		m_writer.Write(LINE_SEPARATOR);
+		m_writer.Write("Content-disposition: form-data; 
+name=\""+name+"\"");
+		m_writer.Write(LINE_SEPARATOR);
+		m_writer.Write(LINE_SEPARATOR);
+		m_writer.Write(val);
+		m_writer.Write(LINE_SEPARATOR);
+	}
+		
+	//============================================================
+========
+	/// <summary>
+	/// Write the specified command/XML pair.
+	/// </summary>
+	/// <param name="cmd">X machine command to be 
+performed</param>
+	/// <param name="node">XML that the command is for</param>
+		
+	internal void Write(string cmd, XmlNode node)
+	{
+		m_writer.Write(START_BOUNDARY);
+		m_writer.Write(LINE_SEPARATOR);
+		m_writer.Write("Content-disposition: form-data; 
+name=\""+cmd+"\"");
+		m_writer.Write(LINE_SEPARATOR);
+		m_writer.Write("Content-Type: "+"text/xml");
+		m_writer.Write(LINE_SEPARATOR);
+		m_writer.Write(LINE_SEPARATOR);
+		XmlTextWriter xtw = new XmlTextWriter(m_writer);
+		node.WriteTo(xtw);
+		m_writer.Write(LINE_SEPARATOR);
+	}
+		
+	//============================================================
+========
+	/// <summary>
+	/// End of message.
+	/// </summary>
+		
+	internal void EndMessage()
+	{
+		m_writer.Write(END_BOUNDARY);
+		m_writer.Flush();
+
+		m_writer.Close();
+	}
+}
+
+public class InsertDocuments
+{
+	/// <summary>
+	/// The main entry point for the application.
+	/// </summary>
+	[STAThread]
+	static void Main(string[] args)
+	{
+		// load the XML data
+		XmlDocument data = new XmlDocument();
+		data.LoadXml(XML);
+
+		HttpPostRequest req = new HttpPostRequest
+("http://localhost:8000");
+		req.Write("_encoding", "utf-8");
+		req.Write("_process", data.DocumentElement);
+		req.EndMessage();
+	}
+
+	const string XML =
+@"<DataBlob>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+<Item>
+1234567890123456789012345678901234567890123456789012345678901234567890
+1234567890
+</Item>
+</DataBlob>
+";
+}
+