http status code for an expired link?
guys which is the correct status code for a link that expires in a certain amount of time?
I have thought to send a 404 after the expiration but maybe there is a bett开发者_如何转开发er http status to send.
Example of link:
mysite/dir/062011/file.exe
(<- working only within 06-2011)
Thanks
How about 410 "Gone"?
See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
410 Gone
The requested resource is no longer available at the server and no forwarding
address is known. This condition is expected to be considered permanent.
I went for 410 Gone when trying to validate an expired verification code in C# Web API. I use REST API Tutorial for reference https://www.restapitutorial.com/httpstatuscodes.html
/// <summary>
/// Verify email address
/// </summary>
/// <param name="verificationCode">Verification Code for ownership of an email address</param>
/// <returns>Verify Email Update Api Response</returns>
[HttpPut]
[Route("{verificationCode}/verify-email-update")]
[ResponseType(typeof(VerifyEmailChangeApiResponse))]
public async Task<IHttpActionResult> VerifyEmailUpdate(Guid verificationCode)
{
var response = await this.emailVerificationService
.VerifyEmailUpdate(verificationCode)
.ConfigureAwait(false);
switch (response.Result)
{
case VerifyEmailUpdateApiResultType.Ok:
return this.Ok(response);
case VerifyEmailUpdateApiResultType.EmailAddressAlreadyVerified:
return this.Content(HttpStatusCode.Conflict, response);
case VerifyEmailUpdateApiResultType.Expired:
return this.Content(HttpStatusCode.Gone, response);
case VerifyEmailUpdateApiResultType.UnknownProblem:
return this.Content(HttpStatusCode.BadRequest, response);
}
return this.Ok(response);
}
精彩评论