Skip to content

Commit 23a793e

Browse files
Merge pull request #12 from dubit/dev_timeout
[Request] Timeout duration
2 parents 6b3406b + b6a982f commit 23a793e

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

HttpRequest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ public bool RemoveHeader(string key)
8787
return headers.Remove(key);
8888
}
8989

90+
public HttpRequest SetTimeout(int duration)
91+
{
92+
unityWebRequest.timeout = duration;
93+
return this;
94+
}
95+
9096
public HttpRequest Send()
9197
{
9298
foreach (var header in headers)

HttpResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class HttpResponse
1414
public ResponseType ResponseType { get; private set; }
1515
public byte[] Bytes { get; private set; }
1616
public string Text { get; private set; }
17+
public string Error { get; private set; }
1718
public Texture Texture { get; private set; }
1819
public Dictionary<string, string> ResponseHeaders { get; private set; }
1920

@@ -25,6 +26,7 @@ public HttpResponse(UnityWebRequest unityWebRequest)
2526
IsSuccessful = !unityWebRequest.isHttpError && !unityWebRequest.isNetworkError;
2627
IsHttpError = unityWebRequest.isHttpError;
2728
IsNetworkError = unityWebRequest.isNetworkError;
29+
Error = unityWebRequest.error;
2830
StatusCode = unityWebRequest.responseCode;
2931
ResponseType = HttpUtils.GetResponseType(StatusCode);
3032
ResponseHeaders = unityWebRequest.GetResponseHeaders();

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ All these methods return the HttpRequest instance.
7474
* `OnDownloadProgress(Action<float> progress)`
7575
##### Configure
7676
* `SetRedirectLimit(int redirectLimit)`
77+
* `SetTimeout(int duration)`
7778

7879
Redirect limit subject to Unity's documentation.
7980
* [Redirect Limit Documentation](https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest-redirectLimit.html)
@@ -99,6 +100,7 @@ This has the following properties:
99100
* `ResponseType ResponseType`
100101
* `byte[] Bytes`
101102
* `string Text`
103+
* `string Error`
102104
* `Texture Texture`
103105
* `Dictionary<string, string> ResponseHeaders`
104106

0 commit comments

Comments
 (0)