http-status-codes

HTTP statuscode to retry same request

天大地大妈咪最大 提交于 2019-12-03 06:39:03
问题 Is there an HTTP status code to instruct a client to perform the same request again? I am facing a situation where the server has to "wait" for a lock to disappear when processing a request. But by the time the lock disappears, the requests might be close to its timeout limit. So instead, once the lock clears, I would like to instruct the client to just perform the same request again. The best I an come up with is a HTTP 307 to the same location, but I'm worried that some browsers might not

Laravel, how to redirect as 301 and 302

社会主义新天地 提交于 2019-12-03 06:30:35
问题 I cannot find info for redirecting as 301/302 in the Laravel docs. In my routes.php file I use: Route::get('foo', function(){ return Redirect::to('/bar'); }); Is this a 301 or 302 by default? Is there a way to set it manually? Any idea why this would be omitted from the docs? 回答1: Whenever you are unsure, you can have a look at Laravel's API documentation with the source code. The Redirector class defines a $status = 302 as default value. You can define the status code with the to() method:

REST HTTP status code if DELETE impossible

和自甴很熟 提交于 2019-12-03 06:15:29
问题 My question is quite a generic one about HTTP status code when a DELETE is impossible on the resource (but not regarding user's rights). We have a RESTful API on a type of resource. The DELETE method is authorized on the resource however under some conditions a resource cannot be deleted (if there are data binded to this resource). What is the correct HTTP status code to return to the client in this situation? Here are some of the possibilities I gathered and why it seems inappropriate in my

HTTP Get with 204 No Content: Is that normal

▼魔方 西西 提交于 2019-12-03 05:30:42
问题 Is it a normal occurrence for an HTTP GET Request to have a response with status code 204 - No Content ? Like, is this semantically correct with respect to what an HTTP GET is supposed to accomplish? I know that a 204 - No Content is okay for an HTTP POST Request . For GET request, if no data is to be sent back, is the 204 status code appropriate? Should I use 404, or just stick to 200 for success but have an empty response? The use case for this question is a Java application that I am

Proper status codes for JSON responses to Ajax calls?

时光怂恿深爱的人放手 提交于 2019-12-03 04:48:01
问题 My project is returning JSON to Ajax calls from the browser. I'm wondering what the proper status code is for sending back with responses to invalid (but successfully handled) data submissions. For example, jQuery has the following two particular callbacks when making Ajax requests: success : Fired when a 200/2xx status code is delivered along with the response. error : Fired when 4xx, 5xx, etc, status codes come back with the response. If a user attempts to create a new "Person" object, I

Are there languages/software that implements http status code 418?

烈酒焚心 提交于 2019-12-03 04:21:19
I know that status code 418 was defined as a April Fools' joke, and "is not expected to be implemented by actual HTTP servers" as is stated on Wikipedia . But I would be interested if any of you knew of a language/webserver/IDE that supports it. I was trying on Apache (via php), and obviously it got me an internal error (500). I just like the humor behind it (am not trying to troll here) and would like to know if more than just Emacs implements this. More precisely: It could be emulated in php for example by doing something like ... header("HTTP/1.1 418 Whatever text I'd like"); ... but do any

Return a specific http status code in Rails

孤街醉人 提交于 2019-12-03 04:05:57
问题 How do you return 503 Service Unavailable in Rails for the entire application? Also, how do you do the same for specific controllers? 回答1: For the entire application: # ApplicationController before_filter :return_unavailable_status private def return_unavailable_status render :nothing => true, :status => :service_unavailable end If you wanted a custom error page, you could do: render 'custom_unavailable_page', :status => :service_unavailable If you don't want it for specific controllers: #

How return 304 status with FileResult in ASP.NET MVC RC1

二次信任 提交于 2019-12-03 02:21:58
As you may know we have got a new ActionResult called FileResult in RC1 version of ASP.NET MVC. Using that, your action methods can return image to browser dynamically. Something like this: public ActionResult DisplayPhoto(int id) { Photo photo = GetPhotoFromDatabase(id); return File(photo.Content, photo.ContentType); } In the HTML code, we can use something like this: <img src="http://mysite.com/controller/DisplayPhoto/657"> Since the image is returned dynamically, we need a way to cache the returned stream so that we don't need to read the image again from database. I guess we can do it with

What HTTP code to use in “Not Authenticated” and “Not authorized” cases?

杀马特。学长 韩版系。学妹 提交于 2019-12-02 22:04:30
I read that "401 Unauthorized" code must be used when a user: Is not logged, but login is required ("not authenticated"); Is logged, but his profile don't allow to see that url ("not authorized"); According to RFC, in both cases server must return 401 code. But I need to differentiate then in my ajax requests. Anybody have a tip to solve this? Note: I don't want to use 403 Forbidden code, because in 403 "Authorization will not help" , according to RFC. rockerest You should pass a custom header in addition to the status code for application specific needs. I believe the current practice is to

Correct HTTP status code for login form?

懵懂的女人 提交于 2019-12-02 20:22:50
I am implementing the authentication for an app, and I am using a pluggable system with "authentication methods". This allows me to implement both HTTP Basic as well as HTML-based authentication. With HTTP Basic/Digest auth the server sends a 401 Unauthorized response header. However, according to the HTTP/1.1 RFC : The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. Since I do not know of any "html" WWW-Authenticate header, sending a 401 with an HTML login form seems inappropriate. Is there any alternative to