Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.utilities.rest 2.5.0 #66

Merged
merged 8 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added CacheDownloads flag to RestParameters
  • Loading branch information
StephenHodgson committed Jan 15, 2024
commit 875c630fd6fc0d8e03c856cfb24ebfe077abaf83
7 changes: 4 additions & 3 deletions Utilities.Rest/Packages/com.utilities.rest/Runtime/Rest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public static bool TryGetFileNameFromUrl(string url, out string fileName)
}
else
{
isCached = TryGetDownloadCacheItem(fileName, out cachePath);
isCached = TryGetDownloadCacheItem(fileName, out cachePath) && (parameters?.CacheDownloads ?? true);
}

if (isCached)
Expand Down Expand Up @@ -583,7 +583,7 @@ public static bool TryGetFileNameFromUrl(string url, out string fileName)
}
else
{
isCached = TryGetDownloadCacheItem(fileName, out cachePath);
isCached = TryGetDownloadCacheItem(fileName, out cachePath) && (parameters?.CacheDownloads ?? true);
}

if (isCached)
Expand Down Expand Up @@ -898,7 +898,8 @@ public static bool TryGetFileNameFromUrl(string url, out string fileName)
TryGetFileNameFromUrl(url, out fileName);
}

if (TryGetDownloadCacheItem(fileName, out var filePath))
if (TryGetDownloadCacheItem(fileName, out var filePath) &&
(parameters?.CacheDownloads ?? true))
{
return filePath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class RestParameters
/// <param name="disposeUploadHandler">Optional, dispose the <see cref="UploadHandler"/>?<br/>Default is true.</param>
/// <param name="certificateHandler">Optional, certificate handler for the request.</param>
/// <param name="disposeCertificateHandler">Optional, dispose the <see cref="CertificateHandler"/>?<br/>Default is true.</param>
/// <param name="cacheDownloads">Optional, cache downloaded content.<br/>Default is true.</param>
/// <param name="debug">Optional,Enabled printing for the debug output of the request.</param>
public RestParameters(
IReadOnlyDictionary<string, string> headers = null,
Expand All @@ -30,6 +31,7 @@ public class RestParameters
bool disposeUploadHandler = true,
CertificateHandler certificateHandler = null,
bool disposeCertificateHandler = true,
bool cacheDownloads = true,
bool debug = false)
{
Headers = headers;
Expand All @@ -39,6 +41,7 @@ public class RestParameters
DisposeUploadHandler = disposeUploadHandler;
CertificateHandler = certificateHandler;
DisposeCertificateHandler = disposeCertificateHandler;
CacheDownloads = cacheDownloads;
Debug = debug;
}

Expand Down Expand Up @@ -82,6 +85,12 @@ public class RestParameters

internal int ServerSentEventCount { get; set; }

/// <summary>
/// Cache downloaded content.<br/>
/// Default is true.
/// </summary>
public bool CacheDownloads { get; set; }

/// <summary>
/// Enabled printing for the debug output of the request.
/// </summary>
Expand Down