This commit is contained in:
@@ -14,7 +14,7 @@ namespace BritishHorseRacingApi
|
||||
{
|
||||
public class ApiClient : BaseApiClient
|
||||
{
|
||||
private const int _waitTimeAfterFail = 20;
|
||||
private const int _waitTimeAfterFail = 5;
|
||||
private const string _userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36";
|
||||
|
||||
public ApiClient(TimeSpan? delay = null) : base(delay) { }
|
||||
@@ -250,9 +250,12 @@ namespace BritishHorseRacingApi
|
||||
var content = response.Content;
|
||||
while (content.StartsWith("<"))
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromMinutes(_waitTimeAfterFail));
|
||||
await Task.Delay(TimeSpan.FromSeconds(_waitTimeAfterFail));
|
||||
//_client.OutgoingPort++;
|
||||
await GetNewToken();
|
||||
_client.DefaultHeaders.Items.RemoveAll(e => e.Key == "Accept-Language");
|
||||
_client.DefaultHeaders.Items.Add(new KeyValuePair<string, string>("Accept-Language", $"en-US,en;q=0.9;id={Guid.NewGuid().ToString()}"));
|
||||
_client.OutgoingPort++;
|
||||
response = await SendRequest(endpoint);
|
||||
content = response.Content;
|
||||
}
|
||||
@@ -282,6 +285,7 @@ namespace BritishHorseRacingApi
|
||||
message.Headers.Add("Authorization", CurrentToken);
|
||||
message.Headers.Add("Accept", "application/json");
|
||||
message.Headers.Add("accept-encoding", "gzip, deflate");
|
||||
if(!_client.DefaultHeaders.Items.Any(e => e.Key == "Accept-Language"))
|
||||
message.Headers.Add("Accept-Language", "en-US,en;q=0.9");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using SuccessfulCodeTools.LowLevelHttpClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
@@ -16,7 +17,7 @@ namespace BritishHorseRacingApi
|
||||
public BaseApiClient(TimeSpan? delay = null)
|
||||
{
|
||||
_delay = delay;
|
||||
_client.DefaultHeaders.Add("Cookie", "bha-ie-test=true; D_SID=188.172.158.138:JT/OEx87nl5ScspTQk38UsDfuIz94DbCf5CYsIC7WpU; _ga=GA1.2.578018316.1549102711; __utmz=36595059.1549187117.8.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __utma=36595059.578018316.1549102711.1550365414.1551216842.16; __utmc=36595059; D_IID=80C3F85C-C90F-31DF-8830-AF181B9C7A2E; D_UID=33DA8B87-0FB7-3D76-9DA6-A650196A2B16; D_ZID=68EA5585-B6A0-34F7-939A-A0C1B40036B3; D_ZUID=0E647F3A-6570-32D2-9673-8B49FFEBE647; D_HID=EBE66F1F-FA2C-3373-8163-110008C50265");
|
||||
//_client.DefaultHeaders.Add("Cookie", "bha-ie-test=true; D_SID=188.172.158.138:JT/OEx87nl5ScspTQk38UsDfuIz94DbCf5CYsIC7WpU; _ga=GA1.2.578018316.1549102711; __utmz=36595059.1549187117.8.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __utma=36595059.578018316.1549102711.1550365414.1551216842.16; __utmc=36595059; D_IID=80C3F85C-C90F-31DF-8830-AF181B9C7A2E; D_UID=33DA8B87-0FB7-3D76-9DA6-A650196A2B16; D_ZID=68EA5585-B6A0-34F7-939A-A0C1B40036B3; D_ZUID=0E647F3A-6570-32D2-9673-8B49FFEBE647; D_HID=EBE66F1F-FA2C-3373-8163-110008C50265");
|
||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user