Client del sito contro il sito di prova (#36, S2)
HttpSiteRequester è l'unica classe che parla col sito: va solo a https://www.instagram.com/ o a un sito di prova di loopback, non segue i rinvii, una richiesta per volta col permesso del Governatore, solo le intestazioni del catalogo con l'user agent della sessione, e registra solo operazione, forma del percorso e stato. Cookie rinnovati e claim finiscono nella sessione (ISiteSession, per ora in memoria; la copia cifrata è S4). SiteAnswerSignals traduce le risposte nei segnali di §7.6: 429 rallenta; rinvii, 401/403, HTML o campi mancanti valgono come Verifica (H16). Il sito di prova risponde alle richieste dirette come dice richieste.prova.json e simula i casi d'arresto; una visita senza sessione viva apre una sessione nuova anche per il client. Nulla è ancora collegato al motore (S3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e10c25d12d
commit
ce9691fe1c
19 files changed
+3563
-51
No files matched your search
@@ -30,6 +30,10 @@ public sealed class SiteAnswer
|
||||
/// <param name="cookiesDeleted">Names of the cookies the site deleted (<c>Set-Cookie</c> expired or empty).</param>
|
||||
/// <param name="setsClaim">True when the site sent a new <c>x-ig-www-claim</c> (<c>x-ig-set-www-claim</c>).</param>
|
||||
/// <param name="retryAfter">What a <c>Retry-After</c> asked to wait, when the site sent one.</param>
|
||||
/// <param name="rootFieldsPresent">
|
||||
/// Whether the body is JSON with every field of <see cref="SiteOperation.RootFields"/>: true or false when the site
|
||||
/// client looked (it does for every answer), null when nobody did (<see cref="SiteAnswerSignals"/> then looks itself).
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentException">A cookie name that is not a plain name (a value must never slip in).</exception>
|
||||
public SiteAnswer(
|
||||
SiteOperation operation,
|
||||
@@ -40,7 +44,8 @@ public sealed class SiteAnswer
|
||||
IEnumerable<string>? cookiesSet = null,
|
||||
IEnumerable<string>? cookiesDeleted = null,
|
||||
bool setsClaim = false,
|
||||
TimeSpan? retryAfter = null)
|
||||
TimeSpan? retryAfter = null,
|
||||
bool? rootFieldsPresent = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(operation);
|
||||
Operation = operation.Name;
|
||||
@@ -54,6 +59,7 @@ public sealed class SiteAnswer
|
||||
CookiesDeleted = Names(cookiesDeleted, nameof(cookiesDeleted));
|
||||
SetsClaim = setsClaim;
|
||||
RetryAfter = retryAfter;
|
||||
RootFieldsPresent = rootFieldsPresent;
|
||||
}
|
||||
|
||||
/// <summary>Name of the catalog operation that was asked.</summary>
|
||||
@@ -92,6 +98,12 @@ public sealed class SiteAnswer
|
||||
/// <summary>What a <c>Retry-After</c> asked to wait (§7.6, Rallentamento).</summary>
|
||||
public TimeSpan? RetryAfter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True when the body is JSON with every expected field of the operation, false when it is not JSON or misses one
|
||||
/// (§6.0: stop and warn), null when it was not looked at.
|
||||
/// </summary>
|
||||
public bool? RootFieldsPresent { get; }
|
||||
|
||||
/// <summary>True when the declared type is JSON, or JavaScript as Instagram serves its GraphQL data (<see cref="DataResponses.IsData"/>).</summary>
|
||||
public bool IsDeclaredData => DataResponses.IsData(MimeType, "Fetch");
|
||||
|
||||
|
||||
Reference in new issue
Block a user