Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
borntocompile committed Nov 15, 2018
2 parents 9454a58 + 23a793e commit bd131d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions HttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public bool RemoveHeader(string key)
return headers.Remove(key);
}

public HttpRequest SetTimeout(int duration)
{
unityWebRequest.timeout = duration;
return this;
}

public HttpRequest Send()
{
foreach (var header in headers)
Expand All @@ -98,6 +104,12 @@ public HttpRequest Send()
return this;
}

public HttpRequest SetRedirectLimit(int redirectLimit)
{
UnityWebRequest.redirectLimit = redirectLimit;
return this;
}

public void Abort()
{
Http.Instance.Abort(this);
Expand Down
2 changes: 2 additions & 0 deletions HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class HttpResponse
public ResponseType ResponseType { get; private set; }
public byte[] Bytes { get; private set; }
public string Text { get; private set; }
public string Error { get; private set; }
public Texture Texture { get; private set; }
public Dictionary<string, string> ResponseHeaders { get; private set; }

Expand All @@ -25,6 +26,7 @@ public HttpResponse(UnityWebRequest unityWebRequest)
IsSuccessful = !unityWebRequest.isHttpError && !unityWebRequest.isNetworkError;
IsHttpError = unityWebRequest.isHttpError;
IsNetworkError = unityWebRequest.isNetworkError;
Error = unityWebRequest.error;
StatusCode = unityWebRequest.responseCode;
ResponseType = HttpUtils.GetResponseType(StatusCode);
ResponseHeaders = unityWebRequest.GetResponseHeaders();
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ All these methods return the HttpRequest instance.
##### Progress
* `OnUploadProgress(Action<float> progress)`
* `OnDownloadProgress(Action<float> progress)`
##### Configure
* `SetRedirectLimit(int redirectLimit)`
* `SetTimeout(int duration)`

Redirect limit subject to Unity's documentation.
* [Redirect Limit Documentation](https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest-redirectLimit.html)

Progress events will invoke each time the progress value has increased, they are subject to Unity's documentation.
* [Upload Progress Documentation](https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest-uploadProgress.html)
Expand All @@ -94,6 +100,7 @@ This has the following properties:
* `ResponseType ResponseType`
* `byte[] Bytes`
* `string Text`
* `string Error`
* `Texture Texture`
* `Dictionary<string, string> ResponseHeaders`

Expand Down

0 comments on commit bd131d1

Please sign in to comment.