Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion AutoUpdater.NET/AutoUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ public static class AutoUpdater
/// </summary>
public static Mode UpdateMode;

/// <summary>
/// Set the timeout in milliseconds for WebRequest of WebClient, default is 100000ms
/// </summary>
public static int Timeout = 100000;

/// <summary>
/// An event that developers can use to exit the application gracefully.
/// </summary>
Expand Down Expand Up @@ -734,7 +739,8 @@ internal static MyWebClient GetWebClient(Uri uri, IAuthentication basicAuthentic
{
var webClient = new MyWebClient
{
CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)
CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore),
Timeout = AutoUpdater.Timeout
};

if (Proxy != null)
Expand Down
13 changes: 13 additions & 0 deletions AutoUpdater.NET/MyWebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,24 @@ public class MyWebClient : WebClient
/// </summary>
public Uri ResponseUri;

/// <summary>
/// Set Request timeout in milliseconds
/// </summary>
public int Timeout;

/// <inheritdoc />
protected override WebResponse GetWebResponse(WebRequest request, IAsyncResult result)
{
WebResponse webResponse = base.GetWebResponse(request, result);
ResponseUri = webResponse.ResponseUri;
return webResponse;
}

/// <inheritdoc />
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest webRequest = base.GetWebRequest(address);
webRequest.Timeout = Timeout;
return webRequest;
}
}