[Mono-bugs] [Bug 45463][Wis] Changed - WebResponse returning NULL half-way through stream sometimes
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Sun, 20 Jul 2003 00:55:34 -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 miguel@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=45463
--- shadow/45463 Sat Jul 19 13:01:48 2003
+++ shadow/45463.tmp.11010 Sun Jul 20 00:55:34 2003
@@ -103,6 +103,121 @@
------- Additional Comments From miguel@ximian.com 2003-07-19 13:01 -------
More details: Mozilla sends "Accept-Encoding: gzip,deflate", the reply
comes at home as chunked compressed.
+
+------- Additional Comments From miguel@ximian.com 2003-07-20 00:55 -------
+Ok, we have found a test case to expose the bug in Mono.
+
+The problem happens *sometimes* when there is a delay in sending the
+information during a chunked transfer.
+
+So if the chunked protocol says `Am sending 2000 bytes', and Mono
+receives 1000 bytes, and then after a pause another 1000 bytes, it
+will fail.
+
+I got this idea from browing the mono code, and I did notice that at
+some point if the chunkedStream has been created, it will not only
+reuse it, but it will *reset it* first, and then append the data it
+just received. This might not be the bug, but was the source of the
+idea.
+
+I have a sample Perl program that can be used as a server: Mozilla and
+Curl will correctly render all the information sent; While Mono will
+always get this wrong.
+
+The correct output should be:
+
+<html><body>La de da
+123456789abcdefghijk</body></html>
+
+While Mono gets:
+<html><body>La de da
+
+Perl code and client follow.
+use IO::Socket;
+ use Net::hostent; # for OO version of gethostbyaddr
+
+ $PORT = 9000; # pick something not in use
+
+ $server = IO::Socket::INET->new( Proto => 'tcp',
+ LocalPort => $PORT,
+ Listen => SOMAXCONN,
+ Reuse => 1);
+
+sub ss {
+ my ($s) = @_;
+ print "Sending: $s\n";
+ printf $client "%x\r\n", length ($s);
+ print $client "$s\r\n";
+}
+
+sub slow {
+ my ($a, $b) = @_;
+ print "Sending: $a and $b\n";
+ printf $client "%x\r\n", length ($a) + length ($b);
+ print $client "$a";
+ sleep 1;
+ print $client "$b\r\n";
+}
+
+while ($client = $server->accept()) {
+ $client->autoflush(1);
+ $a = <$client>; print "$a";
+ $a = <$client>; print "$a";
+ $a = <$client>; print "$a";
+
+ print $client "HTTP/1.1 200 OK\n";
+ print $client "Date: Thu, 26 Jun 2003 19:20:46 GMT\n";
+ print $client "Set-Cookie:
+PREF=ID=41462726307f3c15:TM=1056655246:LM=1056655246:S=U--vIvENfVsOsKF7;
+expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com\n";
+ print $client "Cache-control: private\n";
+ print $client "Content-Type: text/html\n";
+ print $client "Transfer-Encoding: chunked\n";
+ print $client "Server: GWS/2.1\n";
+ print $client "\n";
+ ss "<html><body>";
+ ss "La de da\n";
+ slow "123456789", "abcdefghijk";
+ ss "</body></html>";
+ close $client;
+ }
+
+C# code:
+
+using System;
+using System.IO;
+using System.Net;
+
+class Test {
+
+ static void Main ()
+ {
+ string url = "http://localhost:9000/";
+
+ HttpWebRequest req = (HttpWebRequest)WebRequest.Create (url);
+ WebResponse resp = req.GetResponse ();
+ StreamReader input = new StreamReader (resp.GetResponseStream ());
+
+ string buf;
+ bool feof = false;
+
+ do {
+ buf = input.ReadLine ();
+
+ if (buf == null)
+ feof = true;
+ else {
+ Console.WriteLine (String.Format ("buf: {0}", buf));
+ }
+
+
+ } while (feof);
+ }
+}
+
+
+
+