Cosa deve includere un errore HTTP ritentabile?
«Riprova più tardi» non basta. Il client deve sapere se la condizione è temporanea, quando riprovare e se il primo tentativo ha avuto effetto. Usa status e Retry-After con estensioni Problem Details specifiche dell’API.
«Riprova più tardi» non basta. Il client deve sapere se la condizione è temporanea, quando riprovare e se il primo tentativo ha avuto effetto. Usa status e Retry-After con estensioni Problem Details specifiche dell’API.
HTTP/1.1 503 Service Unavailable
Retry-After: 5
Content-Type: application/problem+json
{
"type": "https://api.example.com/problems/temporarily-unavailable",
"title": "Service temporarily unavailable",
"status": 503,
"detail": "The request was not accepted. Retry after the indicated delay.",
"instance": "urn:request:01JEXAMPLE",
"retryable": true,
"operation_result": "not_applied",
"request_id": "01JEXAMPLE"
}Recommended fields and retry safety
503 segnala indisponibilità temporanea; 429 il limite di richieste. Retry-After indica secondi di attesa o una data HTTP. Usa un type stabile o un codice documentato, senza analizzare detail libero. retryable e operation_result nell’esempio sono estensioni API, non campi standard RFC.
Sources
[RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html)
[RFC 6585](https://www.rfc-editor.org/rfc/rfc6585.html)
[RFC 9457](https://www.rfc-editor.org/rfc/rfc9457.html)