forked from sim0n00ps/OF-DL
Adding missed response body logging and API rate limiting
This commit is contained in:
parent
0dccb0ca9c
commit
d304c1bb6a
@ -391,6 +391,7 @@ public class APIHelper : IAPIHelper
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
var body = await response.Content.ReadAsStringAsync();
|
||||
WriteRawBody($"user-{endpoint.Replace("/", "_")}", body);
|
||||
user = JsonConvert.DeserializeObject<Entities.User>(body, m_JsonSerializerSettings);
|
||||
return user;
|
||||
}
|
||||
@ -812,7 +813,7 @@ public class APIHelper : IAPIHelper
|
||||
highlight_request.Headers.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
|
||||
await EnforceApiRateLimitAsync(CurrentDiagnosticLogger);
|
||||
await EnforceApiRateLimitAsync(CurrentDiagnosticLogger, highlight_request.RequestUri?.ToString());
|
||||
using var highlightResponse = await highlight_client.SendAsync(highlight_request);
|
||||
highlightResponse.EnsureSuccessStatusCode();
|
||||
var highlightBody = await highlightResponse.Content.ReadAsStringAsync();
|
||||
@ -2237,7 +2238,8 @@ public class APIHelper : IAPIHelper
|
||||
{ "skip_users", "all" }
|
||||
};
|
||||
|
||||
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config));
|
||||
var body = await BuildHeaderAndExecuteRequests(getParams, endpoint, GetHttpClient(config), CurrentDiagnosticLogger, "posts-paid-all-initial");
|
||||
WriteRawBody("posts-paid-all-initial", body);
|
||||
purchased = JsonConvert.DeserializeObject<Purchased>(body, m_JsonSerializerSettings);
|
||||
if (purchased != null && purchased.hasMore)
|
||||
{
|
||||
@ -2255,12 +2257,13 @@ public class APIHelper : IAPIHelper
|
||||
{
|
||||
looprequest.Headers.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
await EnforceApiRateLimitAsync(CurrentDiagnosticLogger);
|
||||
await EnforceApiRateLimitAsync(CurrentDiagnosticLogger, looprequest.RequestUri?.ToString());
|
||||
using (var loopresponse = await loopclient.SendAsync(looprequest))
|
||||
{
|
||||
loopresponse.EnsureSuccessStatusCode();
|
||||
var loopbody = await loopresponse.Content.ReadAsStringAsync();
|
||||
newPurchased = JsonConvert.DeserializeObject<Purchased>(loopbody, m_JsonSerializerSettings);
|
||||
WriteRawBody($"posts-paid-all-page-{getParams["offset"]}", loopbody);
|
||||
}
|
||||
purchased.list.AddRange(newPurchased.list);
|
||||
if (!newPurchased.hasMore)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user