Bug 21467 - IHttpAsyncHandler doesn't call EndProcessRequest
Summary: IHttpAsyncHandler doesn't call EndProcessRequest
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-21 03:45 UTC by damirainullin
Modified: 2015-01-31 12:47 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description damirainullin 2014-07-21 03:45:53 UTC
IHttpAsyncHandler doesn't work with Mono (Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4ubuntu1), Ubuntu 14.04). After completing request.BeginGetResponse AsyncCallback doesn't call EndProcessRequest.


    public bool IsReusable { get { return true; } }

    public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
    {
        var request = (HttpWebRequest)HttpWebRequest.Create("http://www.bing.com/");
        request.Method = context.Request.HttpMethod;
        request.UserAgent = context.Request.UserAgent;
        request.Accept = string.Join(",", context.Request.AcceptTypes);
        return request.BeginGetResponse(cb, new object[] { context, request });
    }

    public void EndProcessRequest(IAsyncResult result)
    {
       // EndProcessRequest never called
        var context = (HttpContext)((object[])result.AsyncState)[0];
        var request = (HttpWebRequest)((object[])result.AsyncState)[1];
        using (var response = request.EndGetResponse(result))
        {
            context.Response.ContentType = response.ContentType;
            context.Response.Flush();
        }
    }


Stackoverflow link:
http://stackoverflow.com/questions/24824231/mono-ihttpasynchandler-doesnt-call-endprocessrequest
Comment 1 chrishwang 2015-01-31 12:47:51 UTC
I meet the the same error.

besides if the BeginProcessRequest return IAsyncResult with IsCompleted and CompletedSynchronously is true, the EndProcessRequest didn't be call as the same.

	public class Handler1 : IHttpAsyncHandler
	{
		public void ProcessRequest(HttpContext context)
		{
			//context.Response.ContentType = "text/plain";
			//context.Response.Write("Hello World Sync");
		}

		public bool IsReusable
		{
			get
			{
				return false;
			}
		}

		public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
		{
			var ar = new ServiceAsyncResult
			{
				AsyncState = context,
				IsCompleted = true,
				CompletedSynchronously = true,
				AsyncWaitHandle = null,
			};
			return ar;
		}

		public void EndProcessRequest(IAsyncResult result)
		{
			var context = result.AsyncState as HttpContext;
			if (context != null)
			{
				context.Response.ContentType = "text/plain";
				context.Response.Write("Hello World Async");
			}
		}
	}

Note You need to log in before you can comment on or make changes to this bug.