Skip to content
Open
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: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.6.3] - 2025-11-22

### Fixed
- Fixed **ArgumentNullException** when calling `Abort()` or accessing properties on completed requests ([#103](https://github.com/proyecto26/RestClient/issues/103)).
- Enhanced disposal detection for UnityWebRequest objects to prevent crashes during cleanup scenarios.
- Added proper exception handling for all RequestHelper properties that access disposed UnityWebRequest instances.
- Improved thread safety for request cancellation in Unity's OnDestroy patterns.

## [2.6.2] - 2021-12-26

### Added
Expand Down
58 changes: 52 additions & 6 deletions src/Proyecto26.RestClient/Helpers/RequestHelperExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ public float UploadProgress
float progress = 0;
if (this.Request != null)
{
progress = this.Request.uploadProgress;
try
{
progress = this.Request.uploadProgress;
}
catch (ArgumentNullException)
{
// Request was disposed - return 0 progress
progress = 0;
}
}
return progress;
}
Expand All @@ -36,7 +44,15 @@ public ulong UploadedBytes
ulong bytes = 0;
if (this.Request != null)
{
bytes = this.Request.uploadedBytes;
try
{
bytes = this.Request.uploadedBytes;
}
catch (ArgumentNullException)
{
// Request was disposed - return 0 bytes
bytes = 0;
}
}
return bytes;
}
Expand All @@ -52,7 +68,15 @@ public float DownloadProgress
float progress = 0;
if (this.Request != null)
{
progress = this.Request.downloadProgress;
try
{
progress = this.Request.downloadProgress;
}
catch (ArgumentNullException)
{
// Request was disposed - return 0 progress
progress = 0;
}
}
return progress;
}
Expand All @@ -68,7 +92,15 @@ public ulong DownloadedBytes
ulong bytes = 0;
if (this.Request != null)
{
bytes = this.Request.downloadedBytes;
try
{
bytes = this.Request.downloadedBytes;
}
catch (ArgumentNullException)
{
// Request was disposed - return 0 bytes
bytes = 0;
}
}
return bytes;
}
Expand All @@ -81,10 +113,18 @@ public ulong DownloadedBytes
/// <param name="name">The name of the header.</param>
public string GetHeader(string name)
{
string headerValue;
string headerValue = null;
if (this.Request != null)
{
headerValue = this.Request.GetRequestHeader(name);
try
{
headerValue = this.Request.GetRequestHeader(name);
}
catch (ArgumentNullException)
{
// Request was disposed - fall back to headers dictionary
this.Headers.TryGetValue(name, out headerValue);
}
}
else
{
Expand Down Expand Up @@ -131,6 +171,12 @@ public void Abort()
this.Request.Abort();
}
}
catch (ArgumentNullException)
{
// Request was already disposed by UnityWebRequest's using block - this is expected behavior
// No need to log this as it's a normal part of the request lifecycle
HttpBase.DebugLog(this.EnableDebug, "Request was already disposed; abort skipped.", true);
}
catch (Exception error) {
HttpBase.DebugLog(this.EnableDebug, error.Message, true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proyecto26.RestClient/Proyecto26.RestClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AssemblyName>Proyecto26.RestClient</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<PackageId>Proyecto26.RestClient</PackageId>
<PackageVersion>2.6.2</PackageVersion>
<PackageVersion>2.6.3</PackageVersion>
<Authors>jdnichollsc</Authors>
<PackageIconUrl>https://github.com/proyecto26/RestClient/blob/master/img/icono.png?raw=true</PackageIconUrl>
<PackageLicenseUrl>https://github.com/proyecto26/RestClient/blob/master/LICENSE</PackageLicenseUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/Proyecto26.RestClient/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static System.Version Version
get
{
if (_version == null) {
_version = new System.Version("2.6.2");
_version = new System.Version("2.6.3");
}
return _version;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Proyecto26.RestClient/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.proyecto26.restclient",
"version": "2.6.2",
"version": "2.6.3",
"displayName": "RestClient for Unity",
"description": "Simple HTTP and REST client for Unity based on Promises, also support Callbacks!",
"unity": "2017.1",
Expand Down
Loading