Ricette fatte di richieste, un permesso per richiesta (#36, S3)
Otto ricette (controllo del profilo, storico, taggati, reel, storie di un account, raccolta in evidenza, post singolo, elenco dei seguiti) hanno una strada per richieste dirette accanto a quella con il browser. Ci vanno solo se ogni ruolo che servono è un'operazione configurata di richieste.<sito>.json: con Instagram nessuna lo è e Febe non costruisce il client del sito, quindi il comportamento con Instagram non cambia fino a S4. Ogni richiesta prende il suo permesso dal Governatore nella categoria di ciò che chiede (la prima pagina dei post conta come profilo); i segnali delle risposte vanno all'interruttore e fermano la ricetta prima di ogni altra richiesta. Se manca un valore o la pagina successiva, la ricetta torna alle pagine per quella volta e il motore controlla tutti e due i tetti. I tetti non cambiano: il dimezzamento delle storie viste è tolto perché toccava anche il browser e i «Su misura» salvati, e resta una domanda per Alberto prima di S4. Il simulatore ha --raccolta pagine|richieste con il costo delle operazioni separate di Instagram: sei simulazioni di 30 giorni senza superamenti. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4dcbd0b096
commit
63acae4e73
46 files changed
+3724
-136
No files matched your search
@@ -29,6 +29,33 @@ public enum ScriptedReply
|
||||
|
||||
/// <summary>The sample, with the session cookie deleted by the site.</summary>
|
||||
SessionCookieDeleted,
|
||||
|
||||
/// <summary>A 404 with the JSON of the test site («non-trovato»): the resource is not there (H19).</summary>
|
||||
NotFoundJson,
|
||||
|
||||
/// <summary>A 500 with JSON: an error of the site.</summary>
|
||||
ServerError500,
|
||||
|
||||
/// <summary>A 503 with JSON: the site is not available.</summary>
|
||||
ServerError503,
|
||||
|
||||
/// <summary>No answer in time (<see cref="SiteUnreachableReason.Timeout"/>).</summary>
|
||||
Timeout,
|
||||
|
||||
/// <summary>No connection (<see cref="SiteUnreachableReason.Unreachable"/>).</summary>
|
||||
Unreachable,
|
||||
|
||||
/// <summary>An answer larger than allowed (<see cref="SiteUnreachableReason.TooLarge"/>).</summary>
|
||||
TooLarge,
|
||||
|
||||
/// <summary>A body that cannot be decoded (<see cref="SiteUnreachableReason.Broken"/>).</summary>
|
||||
Broken,
|
||||
|
||||
/// <summary>
|
||||
/// A 200 with JSON that no reader recognizes (the body of the sample «forma-sconosciuta»), said to have the expected
|
||||
/// fields: what a site that changed its format inside the same fields would send.
|
||||
/// </summary>
|
||||
UnknownShape,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -140,6 +167,23 @@ public sealed class ScriptedRequester : ISiteRequester
|
||||
return new SiteAnswer(operation, 302, "text/html", ReadOnlyMemory<byte>.Empty, redirectTo: ChallengeLocation);
|
||||
case ScriptedReply.HtmlInsteadOfJson:
|
||||
return new SiteAnswer(operation, 200, "text/html; charset=utf-8", Encoding.UTF8.GetBytes("<!DOCTYPE html><html><head><title>Pagina</title></head><body></body></html>"));
|
||||
case ScriptedReply.NotFoundJson:
|
||||
return new SiteAnswer(operation, 404, "application/json", Encoding.UTF8.GetBytes("{\"errore\":\"non-trovato\"}"), rootFieldsPresent: false);
|
||||
case ScriptedReply.ServerError500 or ScriptedReply.ServerError503:
|
||||
return new SiteAnswer(operation, reply == ScriptedReply.ServerError500 ? 500 : 503, "application/json", Encoding.UTF8.GetBytes("{\"errore\":\"interno\"}"), rootFieldsPresent: false);
|
||||
case ScriptedReply.Timeout or ScriptedReply.Unreachable or ScriptedReply.TooLarge or ScriptedReply.Broken:
|
||||
var reason = reply switch
|
||||
{
|
||||
ScriptedReply.Timeout => SiteUnreachableReason.Timeout,
|
||||
ScriptedReply.TooLarge => SiteUnreachableReason.TooLarge,
|
||||
ScriptedReply.Broken => SiteUnreachableReason.Broken,
|
||||
_ => SiteUnreachableReason.Unreachable,
|
||||
};
|
||||
throw new SiteUnreachableException($"«{operation.Name}» ({operation.PathShape}): nessuna risposta (prova).", reason);
|
||||
case ScriptedReply.UnknownShape:
|
||||
var unknown = Directory.EnumerateFiles(_samples, "*-forma-sconosciuta.json").Single();
|
||||
var corpo = JsonNode.Parse(File.ReadAllText(unknown))!["corpo"]!;
|
||||
return new SiteAnswer(operation, 200, "application/json", Encoding.UTF8.GetBytes(corpo.ToJsonString()), rootFieldsPresent: true);
|
||||
}
|
||||
|
||||
var (mime, body) = Sample(operation);
|
||||
|
||||
Reference in new issue
Block a user