http-status-codes

Most appropriate HTTP status code for “job in progress”

你。 提交于 2019-12-05 02:28:31
What is the most appropriate HTTP status code to give to a client to mean "your request is fine, but it is still in progress; check back shortly in the exact same place." For example, say the client submits an initial request to start a heavy query, and the server immediately returns a URL that the client can poll periodically for the result. In the case the client calls this URL before the job is completed, what is the most appropriate HTTP status code to return? 202 Accepted would be my first impulse. Is this the best one, or is there a better one that is more idiomatic for this purpose in

Avoiding 304 (not modified) responses

…衆ロ難τιáo~ 提交于 2019-12-05 01:56:08
Is it an ExpiresDefault Apache directive enough to avoid HTTP Status 304 responses from the server? I have set ExpiresDefault "access plus 10 years" but I'm still seeing log entries with a 304 response for "GET /assets/template/default/css/style.min.css?v=1 HTTP/1.1" whenever I open any page on a local PHPMyFAQ site. Emptying the browser cache doesn't seem to change anything. The Expires: header your server sends out has nothing to do with future 304 responses. It provides only an estimate to clients/proxies for how long they can wait before considering a resource "stale." Clients aren't

REST - When to use 400 (“Bad Request”)

橙三吉。 提交于 2019-12-04 22:20:59
I have a resource like this sales/customers/{customerno}. If a client sends a PUT request to this resource I would return 400 - Bad request if the xml in the entity body is not valid xml. But what if the xml is valid, but the content of the xml is not valid. Say for instance that the client is trying to update the customers PostCode and is providing a PostCode which is not valid. Is it correct to return 400 - Bad request in this case, or is it another http code I should have used? From Wikipedia's List of HTTP Status Codes : 400 Bad Request: The request cannot be fulfilled due to bad syntax.

HTTP 200 or 404 for empty list?

泪湿孤枕 提交于 2019-12-04 18:25:55
问题 I know this is a fairly common question, but I haven't found an answer that satisfies me. I've been using django rest framework for a while now, but this is mostly irrelevant other than the example given. Its default behaviour is to return an HTTP 200 with an empty list resource when accessing a route with an empty list of items. E.g.: if we had a route such as /articles/ to access a list of articles but it contained no items we would get a response like the following json: {"count":0, "next"

How to access HTTP StatusDescription in custom error page

不羁岁月 提交于 2019-12-04 16:17:28
When an action (asp.net mvc 5) cannot find something in the database, the user must see a page with a short custom error message e.g. "Invoice 5 does not exist" . Also, the response must have a 404 HTTP code. Another example: when the action is improperly called, the user must see e.g. "Parameter 'invoiceId' is required" . Also, the response must have a 400 HTTP code. I tried to store the custom messages in the HTTP status description and to display them in custom error pages. There are two approaches (afaik): A mvc action: return HttpNotFound("Invoice 5 does not exist"); OR return new

Causing HTTP error status to be returned in WCF

人盡茶涼 提交于 2019-12-04 13:39:55
问题 How can I get my WCF service to communicate errors in a RESTful manner? Specifically, if the caller passes invalid query string parameters to my method, I'd like to have a 400 or 404 HTTP error returned to the user. When I search for HTTP error status in relation to WCF, all I can find are pages where people are trying to resolve errors they're receiving. I'd rather not just throw a FaultException , because that gets converted to a 500 error, which is not the correct status code. 回答1: I found

How to handle specific HTTP error for all AJAX calls?

旧城冷巷雨未停 提交于 2019-12-04 12:10:52
问题 I have a web app, requesting and sending data via AJAX, and as a response, my server-side sends HTTP status codes, depending on the situation. so for example if a user tries to login while he's logged I probably return a 400 HTTP status code . And eventually i handle it with an alert, etc. But handling these HTTP Status codes gets too heavy, since I'm making heavy use of AJAX. that means I'll be handling HTTP status code repeatedly with every AJAX request, which will result in duplicated code

Something faster than get_headers()

风格不统一 提交于 2019-12-04 09:33:53
问题 I'm trying to make a PHP script that will check the HTTP status of a website as fast as possible. I'm currently using get_headers() and running it in a loop of 200 random urls from mysql database. To check all 200 - it takes an average of 2m 48s. Is there anything I can do to make it (much) faster? (I know about fsockopen - It can check port 80 on 200 sites in 20s - but it's not the same as requesting the http status code because the server may responding on the port - but might not be

Setting Context.Response.StatusCode does not seem to work

允我心安 提交于 2019-12-04 07:35:10
I have an HttpHandler with the following code: using System; using System.Web; using Company.Cms; using Company.Web.Handlers.Console; namespace Company.Web.Handlers { /// <summary> /// Summary description for AdminHandler /// </summary> public class AdminHandler : IHttpHandler { public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; HttpResponse response = context.Response; string action = request.QueryString["action"]; if (!HttpContext.Current.User.CanAdminister()) { response.StatusCode = 403; response.Status =

HTTP status code for limited collection?

左心房为你撑大大i 提交于 2019-12-04 06:14:32
I have a restful service where one of the collections is limited (for UX reasons). In this case it has a cap of 25 items. If that is exceeded resources must be deleted before more can be added. As an example if a client submits: POST http://somesite.com/api/v2/stuff {"cool":"stuff"} and there are < 25 things in stuff: 200 OK if > 25 things in stuff: ??? DELETE http://somesite.com/api/v2/stuff/:id POST http://somesite.com/api/v2/stuff {"cool":"stuff"} 200 OK What is the best code for this? Straight 400? 409 CONFLICT? 429? None seem quite right.. Use 409. From httpbis section 7.5.8 : "The