/// <summary> /// Returns the <see cref="WebResponse"/> to a request for a resource located at the supplied <see cref="Uri"/> using the specified <see cref="ICredentials">credentials</see> and <see cref="IWebProxy">proxy</see>. /// </summary> /// <param name="source">A <see cref="Uri"/> that points to the location of the resource to be retrieved.</param> /// <param name="options">A <see cref="WebRequestOptions"/> that holds options that should be applied to web requests.</param> /// <returns> /// An <see cref="WebResponse"/> that contains the response from the requested resource. If unable to create a <see cref="WebResponse"/> for /// the requested <paramref name="source"/>, returns a <b>null</b> reference (Nothing in Visual Basic). /// </returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public static WebResponse CreateWebResponse(Uri source, WebRequestOptions options) { WebResponse response = null; Guard.ArgumentNotNull(source, "source"); WebRequest webRequest = SyndicationEncodingUtility.CreateWebRequest(source, options); if (webRequest != null) { response = webRequest.GetResponse(); } return(response); }
/// <summary> /// Returns a <see cref="WebRequest"/> that makes a request for a resource located at the supplied <see cref="Uri"/> using the specified <see cref="ICredentials">credentials</see> and <see cref="IWebProxy">proxy</see>. /// </summary> /// <param name="source">A <see cref="Uri"/> that points to the location of the resource to be retrieved.</param> /// <param name="credentials"> /// A <see cref="ICredentials"/> that provides the proper set of credentials to the <paramref name="source"/> resource when required. /// If <paramref name="credentials"/> is <b>null</b>, request is made using the default application credentials if supported by the underlying protocol. /// </param> /// <param name="proxy"> /// A <see cref="IWebProxy"/> that provides proxy access to the <paramref name="source"/> resource when required. /// If <paramref name="proxy"/> is <b>null</b>, request is made using the <see cref="WebRequest"/> default proxy settings if supported by the underlying protocol. /// </param> /// <returns> /// An <see cref="WebRequest"/> that makes a request to the <paramref name="source"/>. If unable to create a <see cref="WebRequest"/> for /// the specified <paramref name="source"/>, returns a <b>null</b> reference (Nothing in Visual Basic). /// </returns> /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception> public static WebRequest CreateWebRequest(Uri source, ICredentials credentials, IWebProxy proxy) { return(SyndicationEncodingUtility.CreateWebRequest(source, new WebRequestOptions(credentials, proxy))); }