internal void FireSendingRequest2(Descriptor descriptor)
        {
            HttpWebRequestMessage requestMessage = this.requestMessage as HttpWebRequestMessage;

            if (!this.IsBatchPartRequest)
            {
                if (this.GetHeader("Accept") == null)
                {
                    string headerValue = this.AllowAnyAcceptType ? "*/*" : "application/atom+xml,application/xml";
                    this.SetHeader("Accept", headerValue);
                }
                requestMessage.HttpWebRequest.SendChunked = this.SendChunked;
            }
            if (this.requestInfo.HasSendingRequest2EventHandlers)
            {
                HttpWebRequest       request  = (requestMessage == null) ? null : requestMessage.HttpWebRequest;
                IODataRequestMessage message2 = this.requestMessage;
                if ((requestMessage == null) || (request == null))
                {
                    message2 = new InternalODataRequestMessage(this.requestMessage);
                }
                if (requestMessage != null)
                {
                    requestMessage.BeforeSendingRequest2Event();
                }
                this.requestInfo.FireSendingRequest2(new SendingRequest2EventArgs(message2, descriptor, this.IsBatchPartRequest));
                if (requestMessage != null)
                {
                    requestMessage.AfterSendingRequest2Event();
                }
            }
        }
Exemple #2
0
            /// <summary>
            /// Fires the WritingRequest event
            /// </summary>
            internal override void FireWritingRequest()
            {
                if (!this.requestInfo.HasWritingRequestEventHandlers)
                {
                    return;
                }

                InternalODataRequestMessage internalRequestMessage = this.requestMessage as InternalODataRequestMessage;

                Debug.Assert(internalRequestMessage != null, "Invalid request message instance");
                internalRequestMessage.FireWritingRequest(this.IsBatchPartRequest, this.requestInfo);
            }
Exemple #3
0
        /// <summary>
        /// Create a request message for a batch part from the batch writer. This method copies request headers
        /// from <paramref name="requestMessageArgs"/> in addition to the method and Uri.
        /// </summary>
        /// <param name="batchWriter">ODataBatchWriter instance to build operation message from.</param>
        /// <param name="requestMessageArgs">RequestMessageArgs for the request.</param>
        /// <param name="requestInfo">RequestInfo instance.</param>
        /// <returns>an instance of ODataRequestMessageWrapper.</returns>
        internal static ODataRequestMessageWrapper CreateBatchPartRequestMessage(
            ODataBatchWriter batchWriter,
            BuildingRequestEventArgs requestMessageArgs,
            RequestInfo requestInfo)
        {
            IODataRequestMessage requestMessage = batchWriter.CreateOperationRequestMessage(requestMessageArgs.Method, requestMessageArgs.RequestUri);

#if WINDOWS_PHONE
            if (requestInfo.HasWritingRequestEventHandlers)
            {
                // We use the InternalODataRequestMessage constructor here beecause we want to allow the user to be able to access the underlying request stream.
                requestMessage = new InternalODataRequestMessage(requestMessage, true);
            }
#endif
            foreach (var h in requestMessageArgs.Headers)
            {
                requestMessage.SetHeader(h.Key, h.Value);
            }

            var clientRequestMessage = new InternalODataRequestMessage(requestMessage, false /*allowGetStream*/);
            ODataRequestMessageWrapper messageWrapper = new InnerBatchRequestMessageWrapper(clientRequestMessage, requestMessage, requestInfo, requestMessageArgs.Descriptor);
            return(messageWrapper);
        }
 internal void FireSendingRequest2(Descriptor descriptor)
 {
     HttpWebRequestMessage requestMessage = this.requestMessage as HttpWebRequestMessage;
     if (!this.IsBatchPartRequest)
     {
         if (this.GetHeader("Accept") == null)
         {
             string headerValue = this.AllowAnyAcceptType ? "*/*" : "application/atom+xml,application/xml";
             this.SetHeader("Accept", headerValue);
         }
         requestMessage.HttpWebRequest.SendChunked = this.SendChunked;
     }
     if (this.requestInfo.HasSendingRequest2EventHandlers)
     {
         HttpWebRequest request = (requestMessage == null) ? null : requestMessage.HttpWebRequest;
         IODataRequestMessage message2 = this.requestMessage;
         if ((requestMessage == null) || (request == null))
         {
             message2 = new InternalODataRequestMessage(this.requestMessage);
         }
         if (requestMessage != null)
         {
             requestMessage.BeforeSendingRequest2Event();
         }
         this.requestInfo.FireSendingRequest2(new SendingRequest2EventArgs(message2, descriptor, this.IsBatchPartRequest));
         if (requestMessage != null)
         {
             requestMessage.AfterSendingRequest2Event();
         }
     }
 }