[Mono-bugs] [Bug 419730] New: HttpWebRequest. CheckFinalStatus sometimes hangs and results in read timeout

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Aug 22 16:19:48 EDT 2008


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: jbevain at novell.com
        ReportedBy: awhite at ipswitch.com
         QAContact: mono-bugs at lists.ximian.com
          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.


More information about the mono-bugs mailing list