Skip to content

Commit a8938b9

Browse files
committed
fixes #37
1 parent e31176f commit a8938b9

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

UniFiSharp/DefaultUniFiRestClient.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ internal DefaultUniFiRestClient(Uri baseUrl, string username, string password, b
3535
// Bodge to work around the fact uploads don't return the normal metadata if unauthorized (migrated to RestClientOptions)
3636
FollowRedirects = true,
3737
Encoding = encoding ?? Encoding.UTF8,
38-
Timeout = timeout,
39-
ThrowOnAnyError = true
40-
})
38+
Timeout = TimeSpan.FromMilliseconds(timeout),
39+
ThrowOnAnyError = true
40+
}, configureSerialization: serializerConfig => serializerConfig.UseNewtonsoftJson())
4141
{
4242
_username = username;
4343
_password = password;
4444
_useModernApi = useModernApi;
4545
_baseUrl = baseUrl;
4646

47-
this.UseNewtonsoftJson();
4847
}
4948
#nullable disable
5049

@@ -256,8 +255,8 @@ private async Task ApplyRequestHeaders(RestRequest request)
256255
{
257256
request.AddHeader("Referrer", _baseUrl.ToString());
258257

259-
if (CookieContainer.GetCookies(_baseUrl).Count > 0 && CookieContainer.GetCookies(_baseUrl)["csrf_token"]?.Value != null)
260-
_csrf_token = CookieContainer.GetCookies(_baseUrl)["csrf_token"]?.Value;
258+
if (Options.CookieContainer.GetCookies(_baseUrl).Count > 0 && Options.CookieContainer.GetCookies(_baseUrl)["csrf_token"]?.Value != null)
259+
_csrf_token = Options.CookieContainer.GetCookies(_baseUrl)["csrf_token"]?.Value;
261260

262261
if (_csrf_token == null)
263262
{
@@ -272,4 +271,4 @@ private async Task ApplyRequestHeaders(RestRequest request)
272271
}
273272
}
274273
}
275-
}
274+
}

0 commit comments

Comments
 (0)