Esempio n. 1
0
        public override void Process(IODataRequestMessage requestMessage, IODataResponseMessage responseMessage)
        {
            string    asyncToken = this.QueryContext.AsyncToken;
            AsyncTask asyncTask  = AsyncTask.GetTask(asyncToken);

            if (asyncTask == null)
            {
                // token is invalid or expired.
                throw Utility.BuildException(HttpStatusCode.NotFound);
            }
            else
            {
                if (!asyncTask.Ready)
                {
                    ResponseWriter.WriteAsyncPendingResponse(responseMessage, asyncToken);
                }
                else
                {
                    responseMessage.SetHeader(ServiceConstants.HttpHeaders.ContentType, "application/http");
                    responseMessage.SetHeader(ServiceConstants.HttpHeaders.ContentTransferEncoding, ServiceConstants.HttpHeaderValues.Binary);
                    using (var messageWriter = this.CreateMessageWriter(responseMessage))
                    {
                        var asyncWriter   = messageWriter.CreateODataAsynchronousWriter();
                        var innerResponse = asyncWriter.CreateResponseMessage();
                        asyncTask.Execute(innerResponse);
                    }
                }
            }
        }