https://bugzilla.novell.com/show_bug.cgi?id=419730
Summary: HttpWebRequest.CheckFinalStatus sometimes hangs and
results in read timeout
Product: Mono: Class Libraries
Version: 2.0
Platform: i686
OS/Version: openSUSE 10.3
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Core
AssignedTo: [EMAIL PROTECTED]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
Found By: Community User
Found this when reading from Amazon's S3 Web Service. Reading a S3 bucket that
does exist works fine, but a bucket that does not exist causes the hang and
then read timeout.
Code to reproduce:
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Test404
{
class MainClass
{
public static void Main(string[] args)
{
HttpWebRequest req =
(HttpWebRequest)WebRequest.Create("http://no.eggs.com.s3.amazonaws.com/");
req.Method = "GET";
req.AllowWriteStreamBuffering = false;
req.KeepAlive = true;
HttpWebResponse resp;
try
{
resp = (HttpWebResponse)req.GetResponse();
}
catch (System.Net.WebException ex)
{
Console.WriteLine("ex :"+ex);
resp = (HttpWebResponse)ex.Response;
}
Console.WriteLine(resp.StatusCode);
Console.WriteLine(resp.StatusDescription);
resp.Close();
}
}
}
Info:
I tracked the issue down to HttpWebRequest.CheckFinalStatus. I cannot say if
this is the "correct" solution but it may give a hint about what was happening.
if ((int) code >= 400) {
string err = String.Format ("The remote server returned an error: ({0})
{1}.",
(int) code, webResponse.StatusDescription);
throwMe = new WebException (err, null, protoError, webResponse);
// webResponse.ReadAll ();
if (resp != null)
resp.ReadAll ();
by replacing webResponse.ReadAll (); with resp.ReadAll (); my S3 example
worked. For what that's worth.
btw - there is another webResponse.ReadAll (); a few lines down that may also
need replacing/reviewing
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs