http-status-codes

how to handle httpStatuscode correctly

我的梦境 提交于 2019-12-07 05:59:32
问题 I would like to react on http status-codes (like 200, 201 or 202) with the new feature (http://api.jquery.com/jQuery.ajax). But the function is ignoring my 201 and 202 callbacks. This error occures with firefox-4.0_b10 and chromium-9.0 I'm looking forward to fix this little issue. Regards Stefan My code-snipped: jQuery.ajax({ url: url, dataType: 'json', statusCode: { 404:function() { alert("404"); }, 200:function() { alert("200"); }, 201:function() { alert("201"); }, 202:function() { alert(

Response.Redirect() vs Response.RedirectPermanent()

萝らか妹 提交于 2019-12-07 05:50:48
问题 I am new to ASP.Net 4.0, and have seen a new feature called Response.RedirectPermanent() . I have checked a few articles, but I'm unable to understand clearly the actual meaning and difference of Response.RedirectPermanent() over Response.Redirect() . According to Gunnar Peipman, Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask

Http2 protocol and status messages

独自空忆成欢 提交于 2019-12-07 01:11:53
问题 So i just found out the hard way that the http2 protocol does not support http status messages like 404 Not Found in the old http1.1 protocol. One of our web Api's is using the http status message to return a readable message to the end user. Now my question is, is there a new way of returning status messages in http2 or do we have to return the message in the http response body? 回答1: There is no new standard way, thus either a custom response header or the message body are your only choices.

Most appropriate HTTP status code for “job in progress”

扶醉桌前 提交于 2019-12-06 20:59:53
问题 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

Which Http Status code to return when user provided data fails validation in Web Service?

牧云@^-^@ 提交于 2019-12-06 19:42:34
When the user enters data and submits that data, we pass it to the server using and XMLHttpRequest. But, if that data fails validation, we have to return a 400 level status code. I thought the appropriate code would be 403. However, my colleague doesn't agree but doesn't know which to use. Which one would you use? Thanks! 400 would be more correct, i.e. the request contained invalid data. 403 would imply some kind of permisions error, i.e. the request was well formed and correct but the action was not allowed. If i was writing code to consume a web service and i got a 403 error it would never

HTTP response code when resource creation POST fails due to existing matching resource

时间秒杀一切 提交于 2019-12-06 17:40:36
问题 Imagine we have an API where a new Employee can be created through a POST to www.example.com/api/employees An employee could be described as, { name: "John Smith", tax_number: "ABC123" } The tax number is universally unique for all humans. If a create were made, and a record already existed in which the name and tax number matched an existing record, it is safe to assume the requester would like a reference to that record returned (with it's internal id and other data the client may not have,

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

点点圈 提交于 2019-12-06 16:43:07
问题 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? 回答1: From

http status code for failed email send

て烟熏妆下的殇ゞ 提交于 2019-12-06 10:08:39
Consider an API call that creates a user. On success, the user is created and a confirmation email is sent. The response status code is 201. If the user is not created, the response status code is 422. What should the response status code be if user is created BUT sending the confirmation email failed? The core of the problem lies in mixing a RESTful resource creation and an RPC-style action. The creation of the user, in a RESTful world, would be the atomic operation and return 201 or 422 (or whatever error code you choose). Then the sending of the confirmation email might be another POST to

Check on the status code of url before redirect_to in controller rails

我只是一个虾纸丫 提交于 2019-12-06 07:17:58
I have action check_status in instances_controller , and I want to check on status code of URL before redirect_to it. if status_code is 200 redirect_to it, else go to view page. This is the pseudo-code of check_status action: def check_status if "http://www.web.com".status_code == 200 redirect_to "http://www.web.com" else #DO Nothing, and go to its view end end For example get '/about' => 'instances#check_status' , and i want to check if (web.com) get status=200 visit (web.com) You can do this - but beware: Your user will have to wait for your response check to complete before they get

How to set HTTP status code with JSF?

廉价感情. 提交于 2019-12-06 04:48:22
I use Apache Myfaces 2.2 on WebSphere Application Server. I have a JSF page, which "test" the conenction to filesystem and database. When the connection fails, I want to return another HTTP Status Code. How can I do this with JSF? Try response.setStatus(); for more details this link will be helpful : http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-Response-Status-Line.html 来源: https://stackoverflow.com/questions/11428686/how-to-set-http-status-code-with-jsf