Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.
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
43 changes: 22 additions & 21 deletions src/DropboxRestAPI/RequestExecuter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public RequestExecuter(HttpClient clientContent, HttpClient clientOAuth)
}

if (statusCode == 0)
throw new HttpException((int) statusCode, content) {Attempts = 1};
throw new HttpException((int)statusCode, content) { Attempts = 1 };

if ((int)statusCode == 429 || statusCode == HttpStatusCode.ServiceUnavailable)
{
Expand All @@ -126,21 +126,26 @@ public RequestExecuter(HttpClient clientContent, HttpClient clientOAuth)
if (retryAfter.Value != null && retryAfter.Value.Any())
{
throw new RetryLaterException
{
RetryAfter = decimal.Parse(retryAfter.Value.First(), CultureInfo.InvariantCulture)
};
{
RetryAfter = decimal.Parse(retryAfter.Value.First(), CultureInfo.InvariantCulture)
};
}
}
throw new RetryLaterException {RetryAfter = 10};
throw new RetryLaterException { RetryAfter = 10 };
}
if ((int) statusCode == 507)
if ((int)statusCode == 507)
{
throw new NotEnoughQuotaException();
}
if (statusCode == HttpStatusCode.Unauthorized ||
statusCode == HttpStatusCode.Forbidden ||
statusCode == HttpStatusCode.BadRequest ||
statusCode == HttpStatusCode.ServiceUnavailable)


if (statusCode == HttpStatusCode.InternalServerError ||
statusCode == HttpStatusCode.BadGateway)
{
throw new HttpException((int)statusCode, content ?? httpResponse.ReasonPhrase) { Attempts = int.MaxValue };
}

if ((int)statusCode >= 400)
{
Error errorInfo = null;

Expand All @@ -161,24 +166,20 @@ public RequestExecuter(HttpClient clientContent, HttpClient clientOAuth)
if (!string.IsNullOrEmpty(content))
errorInfo = JsonConvert.DeserializeObject<Error>(content);
if (errorInfo == null || errorInfo.error == null)
throw new HttpException((int) statusCode, content) {Attempts = 1};
throw new HttpException((int)statusCode, content ?? httpResponse.ReasonPhrase) { Attempts = 1 };

string error = errorInfo.error;
if (!string.IsNullOrEmpty(errorInfo.error_description))
error = string.Format("{0}: {1}", errorInfo.error, errorInfo.error_description);

throw new ServiceErrorException((int) statusCode, error)
{
ErrorCode = errorInfo.error,
ErrorDescription = errorInfo.error_description
};
}
if (statusCode == HttpStatusCode.InternalServerError ||
statusCode == HttpStatusCode.BadGateway)
{
throw new HttpException((int) statusCode, content) {Attempts = int.MaxValue};
throw new ServiceErrorException((int)statusCode, error)
{
ErrorCode = httpResponse.ReasonPhrase,
ErrorDescription = errorInfo.error_description
};
}


return content;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace DropboxRestAPI.RequestsGenerators.Core
{
public interface IMetadataRequestGenerator
{
IRequest Files(string root, string path, string rev = null, string asTeamMember = null);
IRequest Files(string root, string path, string rev = null, string asTeamMember = null, bool useGetHttpMethod = false);
IRequest FilesRange(string root, string path, long from, long to, string etag, string rev = null, string asTeamMember = null);

IRequest FilesPut(string root, Stream content, string path, string locale = null, bool overwrite = true, string parent_rev = null, bool autorename = true, string asTeamMember = null);
Expand Down
Loading