A server receives a request, but decides that the request will take to 开发者_如何学编程long to process, so it responds with a site saying Loading.... The site will refresh itself until the client receives the response indicating that the (first) request has been completely processed.
What's the most appropriate status code for this Loading... site?
My guess is that it is 202 Accepted.
HTTP is a request/response protocol. Each request returns a single response.
In your example, the initial request successfully returns your loading page, and so the "success" 200 code is appropriate.
Your example of this page then generating further data is working at a different layer to HTTP, and so doesn't need to add semantics to the HTTP level
For a service that can not give full data response because it's still loading - evert suggestion in the comments is the best.
Return 503 / Service Unavailable
status, if you can estimate the time the service take to load - add Retry-After
Header.
精彩评论