public ShimDataRequestMessage(SendingRequest2EventArgs args)
        {
            _args = args;

            WebRequest = ShimWebHelpers.AddHeaders(HttpWebRequest.CreateHttp(_args.RequestMessage.Url), _args.RequestMessage.Headers);

            WebRequest.Method = _args.RequestMessage.Method;
        }
 private void ChangeAcceptHeader(object sender, SendingRequest2EventArgs e)
 {
     if (e.RequestMessage.GetHeader("content-type") != null)
     {
         e.RequestMessage.SetHeader("content-type", _acceptHeader);
     }
     e.RequestMessage.SetHeader("accept", _acceptHeader);
 }
 /// <summary>
 /// Adds the request version.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.Data.Services.Client.SendingRequestEventArgs"/> instance containing the event data.</param>
 private void AddClientRequestId(object sender, SendingRequest2EventArgs e)
 {
     e.RequestMessage.SetHeader(XMsClientRequestId, _requestId.ToString());
 }
 /// <summary>
 /// Adds user agent.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.Data.Services.Client.SendingRequestEventArgs" /> instance containing the event data.</param>
 private void AddRequestUserAgent(object sender, SendingRequest2EventArgs e)
 {
     e.RequestMessage.SetHeader(HttpRequestHeader.UserAgent.ToString(), _userAgentHeaderValue);
 }
Exemple #5
0
 internal void FireSendingRequest2(SendingRequest2EventArgs eventArgs)
 {
     this.context.FireSendingRequest2(eventArgs);
 }
        private void OnSendingRequest(object sender, SendingRequest2EventArgs e)
        {
            var shimRequest = new ShimDataRequestMessage(e);

            // Initialize the request
            _httpClient.InitializeRequest(shimRequest.WebRequest);


            RaiseSendingRequest(new WebRequestEventArgs(shimRequest.WebRequest));
        }
Exemple #7
0
 private void OdataClientOnSendingRequest2(object sender, SendingRequest2EventArgs sendingRequest2EventArgs)
 {
     ((HttpWebRequestMessage)sendingRequest2EventArgs.RequestMessage).HttpWebRequest.ClientCertificates.Add(this.certificate);
 }
Exemple #8
0
 internal void FireSendingRequest2(SendingRequest2EventArgs eventArgs)
 {
     this.context.FireSendingRequest2(eventArgs);
 }
 /// <summary>
 /// When sending Http Data requests to the Azure Marketplace, inject authorization header based on the current Access token.
 /// </summary>
 /// <param name="sender">Event sender.</param>
 /// <param name="e">Event arguments.</param>
 private void OnSendingRequest(object sender, SendingRequest2EventArgs e)
 {
     if (e.RequestMessage.GetHeader(AuthorizationHeader) == null)
     {
         e.RequestMessage.SetHeader(AuthorizationHeader, _tokenProvider.GetAuthorizationHeader());
     }
 }
 /// <summary>
 /// Adds the request version.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.Data.Services.Client.SendingRequestEventArgs"/> instance containing the event data.</param>
 private void AddRequestVersion(object sender, SendingRequest2EventArgs e)
 {
     e.RequestMessage.SetHeader(_xMsVersion, this._serviceVersion.ToString());
 }
 /// <summary> 
 /// When sending Http Data requests to the Azure Marketplace, inject authorization header based on the current Access token.
 /// </summary> 
 /// <param name="sender">Event sender.</param> 
 /// <param name="e">Event arguments.</param> 
 private void OnSendingRequest(object sender, SendingRequest2EventArgs e)
 {
     if (e.RequestMessage.GetHeader(AuthorizationHeader) == null)
     {
         RefreshToken();
         e.RequestMessage.SetHeader(AuthorizationHeader, string.Format(CultureInfo.InvariantCulture, BearerTokenFormat, this._credentials.AccessToken));
     }
 }