Event arguments for the event of creating a WebRequest
Inheritance: System.EventArgs
		public void ConfigureRequest(RavenConnectionStringOptions options, HttpWebRequest request)
		{
			if (RequestTimeoutInMs.HasValue)
				request.Timeout = RequestTimeoutInMs.Value;

			if (AllowWriteStreamBuffering.HasValue)
			{
				request.AllowWriteStreamBuffering = AllowWriteStreamBuffering.Value;
				if(AllowWriteStreamBuffering.Value == false)
					request.SendChunked = true;
			}

			if (options.ApiKey == null)
			{
				request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
				return;
			}

			var webRequestEventArgs = new WebRequestEventArgs { Request = request, Credentials = new OperationCredentials(options.ApiKey, options.Credentials)};

			AbstractAuthenticator existingAuthenticator;
			if (authenticators.TryGetValue(GetCacheKey(options), out existingAuthenticator))
			{
				existingAuthenticator.ConfigureRequest(this, webRequestEventArgs);
			}
			else
			{
				var basicAuthenticator = new BasicAuthenticator(enableBasicAuthenticationOverUnsecuredHttp: false);
				var securedAuthenticator = new SecuredAuthenticator();

				basicAuthenticator.ConfigureRequest(this, webRequestEventArgs);
				securedAuthenticator.ConfigureRequest(this, webRequestEventArgs);
			}
		}
		public virtual void ConfigureRequest(object sender, WebRequestEventArgs e)
		{
			if (string.IsNullOrEmpty(CurrentOauthToken))
				return;

			SetHeader(e.Request.Headers, "Authorization", CurrentOauthToken);
		}
		public void ConfigureRequest(RavenConnectionStringOptions options, WebRequest request)
		{
			if (RequestTimeoutInMs.HasValue)
				request.Timeout = RequestTimeoutInMs.Value;

			if (options.ApiKey == null)
			{
				request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
				return;
			}

			var webRequestEventArgs = new WebRequestEventArgs { Request = request };

			AbstractAuthenticator existingAuthenticator;
			if (authenticators.TryGetValue(GetCacheKey(options), out existingAuthenticator))
			{
				existingAuthenticator.ConfigureRequest(this, webRequestEventArgs);
			}
			else
			{
				var basicAuthenticator = new BasicAuthenticator(options.ApiKey, enableBasicAuthenticationOverUnsecuredHttp: false);
				var securedAuthenticator = new SecuredAuthenticator(options.ApiKey);

				basicAuthenticator.ConfigureRequest(this, webRequestEventArgs);
				securedAuthenticator.ConfigureRequest(this, webRequestEventArgs);
			}
		}
		public virtual void ConfigureRequest(object sender, WebRequestEventArgs e)
		{
			if (string.IsNullOrEmpty(CurrentOauthToken))
				return;

#if NETFX_CORE
			e.Client.DefaultRequestHeaders.Add("Authorization", CurrentOauthToken);
#else
			SetHeader(e.Request.Headers, "Authorization", CurrentOauthToken);
#endif
			}
		public override void ConfigureRequest(object sender, WebRequestEventArgs e)
		{
			if (CurrentOauthToken != null)
			{
				base.ConfigureRequest(sender, e);
				return;
			}
			if (apiKey != null)
			{
				e.Request.Headers["Has-Api-Key"] = "true";
			}
		}
        protected void SetAuthorization(WebRequestEventArgs e)
        {
            if (string.IsNullOrEmpty(CurrentOauthToken))
                return;

            if (e.Client != null)
            {
                SetAuthorization(e.Client);
            }

            if (e.Request != null)
                SetHeader(e.Request.Headers, "Authorization", CurrentOauthTokenWithBearer);
        }
		protected void SetAuthorization(WebRequestEventArgs e)
		{
			if (string.IsNullOrEmpty(CurrentOauthToken))
				return;

			if (e.Client != null)
			{
				SetAuthorization(e.Client);
			}

#if !NETFX_CORE
			if (e.Request != null)
				SetHeader(e.Request.Headers, "Authorization", CurrentOauthToken);
#endif
		}
        public override void ConfigureRequest(object sender, WebRequestEventArgs e)
        {
            if (CurrentOauthToken != null)
            {
                base.ConfigureRequest(sender, e);
                return;
            }

            if (e.Credentials != null && e.Credentials.ApiKey != null)
            {
                if (e.Client != null)
                    e.Client.DefaultRequestHeaders.Add("Has-Api-Key", "true");
                if (e.Request != null)
                    e.Request.Headers["Has-Api-Key"] = "true";
            }
        }
		public override void ConfigureRequest(object sender, WebRequestEventArgs e)
		{
			if (CurrentOauthToken != null)
			{
				base.ConfigureRequest(sender, e);
				return;
			}
			if (apiKey != null)
			{
#if NETFX_CORE
				e.Client.DefaultRequestHeaders.Add("Has-Api-Key", "true");
#else
				e.Request.Headers["Has-Api-Key"] = "true";
#endif
			}
		}
        public void ConfigureRequest(RavenConnectionStringOptions options, HttpWebRequest request)
        {
            if (RequestTimeoutInMs.HasValue)
                request.Timeout = RequestTimeoutInMs.Value;

            if (options.ApiKey == null)
            {
                ICredentials credentialsToUse = CredentialCache.DefaultNetworkCredentials;
                if (options.Credentials != null)
                {
                    var networkCredentials = options.Credentials as NetworkCredential;
                    if (networkCredentials != null && options.AuthenticationScheme != null)
                    {
                        var credentialCache = new CredentialCache();
                        var uri = new Uri(options.Url);
                        credentialCache.Add(new Uri(string.Format("{0}://{1}:{2}/", uri.Scheme, uri.Host, uri.Port)), options.AuthenticationScheme, networkCredentials);

                        credentialsToUse = credentialCache;
                    }
                    else
                    {
                        credentialsToUse = options.Credentials;
                    }
                }

                request.Credentials = credentialsToUse;
                return;
            }

            var webRequestEventArgs = new WebRequestEventArgs { Request = request, Credentials = new OperationCredentials(options.ApiKey, options.Credentials)};

            AbstractAuthenticator existingAuthenticator;
            if (authenticators.TryGetValue(GetCacheKey(options), out existingAuthenticator))
            {
                existingAuthenticator.ConfigureRequest(this, webRequestEventArgs);
            }
            else
            {
                var basicAuthenticator = new BasicAuthenticator(enableBasicAuthenticationOverUnsecuredHttp: false);
                var securedAuthenticator = new SecuredAuthenticator();

                basicAuthenticator.ConfigureRequest(this, webRequestEventArgs);
                securedAuthenticator.ConfigureRequest(this, webRequestEventArgs);
            }
        }
 public virtual void ConfigureRequest(object sender, WebRequestEventArgs e)
 {
     SetAuthorization(e);
 }
 private static void BeginRequest(object sender, WebRequestEventArgs e)
 {
     var profiler = MiniProfiler.Current;
     if (profiler != null && e.Request != null)
         _Requests.TryAdd(e.Request.RequestUri.PathAndQuery, profiler.Step("RavenDb: Query - " + e.Request.RequestUri.PathAndQuery));
 }
Beispiel #13
0
 private static void BeginRequest(object sender, WebRequestEventArgs e)
 {
     NewRelic.Api.Agent.NewRelic.IncrementCounter("RavenDB/RequestCount");
 }