Dev2.Runtime.ServiceModel.WebSources.EnsureWebClient C# (CSharp) Method

EnsureWebClient() public static method

public static EnsureWebClient ( WebSource source, IEnumerable headers ) : void
source Dev2.Runtime.ServiceModel.Data.WebSource
headers IEnumerable
return void
        public static void EnsureWebClient(WebSource source, IEnumerable<string> headers)
        {
            if(source != null && source.Client != null)
            {
                return;
            }

            if(source != null)
            {
                source.Client = new WebClient();

                if(source.AuthenticationType == AuthenticationType.User)
                {
                    source.Client.Credentials = new NetworkCredential(source.UserName, source.Password);
                }
                source.Client.Headers.Add("user-agent", GlobalConstants.UserAgentString );

                if(headers != null)
                {
                    foreach(var header in headers)
                    {
                        source.Client.Headers.Add(header.Trim());
                    }
                }
            }
        }