http-status-codes

Which HTTP status code to say username or password were incorrect?

北城余情 提交于 2019-11-29 05:30:09
I am implementing a simple registation/login module. While testing user credentials, I start thinking which HTTP status code will be appropriate, for the situation if a user send a request with incorrect credentials. At first, I thought 401 Unauthorized would be a nice status code, but it seems it will be better to use it when a user is trying to get some resource without authorisation. After, I switched to 409 Conflict This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. So, friends, please give me an advise

HTTP Status Code for database is down

荒凉一梦 提交于 2019-11-29 05:24:31
I have a page on my web site that reports on the health of the site and sets an HTTP 200 status code is everything is okay. This page is used by an external monitoring program to check that the site is up. When this page is hit, I make a very lightweight DB proc call to see if the DB is up and okay. If this fails, I want to return a meaningful HTTP error code to the monitor to let it know that all is not well. From what I can work out there's no HTTP status that says "a third party component that I rely on is down" so what what would you return in this case? 503 Service Unavailable...? I would

HTTP status code for “no data available” from an external datasource

自作多情 提交于 2019-11-29 04:49:08
问题 Scenario: A POST request is sent to process an order that will result in data retrieval from an external datasource. There are three possible results: The datasource returned data for the request No data was available for the request (this is viewed as an error) The datasource couldn't be accessed (may be down for maintenance) An obvious response for 1 is 200: OK or 201: Created (an entity is created from this request). What status codes would be appropriate for 2 and 3 ? Status codes I have

how do I check an http request response status code from iOS?

萝らか妹 提交于 2019-11-29 04:09:38
I am sending an http request from iOS (iPad/iPhone) to my python google app engine server using the NSURLConnection and NSURLRequest classes. How do I read the response's status, i.e. the value set by app engine using response.set_status(200, message="Success") for instance? I'm not able to find where I can read these status codes once I receive the NSURLConnection's connectionDidFinishLoading delegate call on the client end. The connection:didReceiveResponse: delegate method is called when a response is received, which gives you an NSURLResponse to play with. If you've made an HTTP request,

HttpStatusCodeResult(401) returns “302 Found”

五迷三道 提交于 2019-11-29 04:01:27
Using ASP.NET MVC 5, I would like to return appropriate HTTP status code for different scenarios (401 for user is not authenticated, 403 when user has no right for some resource, etc.), than handle them in jQuery. But the problem is, when I try to return 401, it always returns "302: Found". What is the trick for a custom status code, and why this doesn't work? public ActionResult My() { if (User.Identity.IsAuthenticated == false) { return new HttpStatusCodeResult(401, "User is not authenticated."); // Returns "302: Found" } // ... other code ... } EDIT 1: Interesting bit: If I replace the 401

Eradicating 401 “Unauthorised” responses followed by 200 “Ok” responses

谁说胖子不能爱 提交于 2019-11-29 02:28:10
问题 I’ve got a situation with a large internal corporate web based application running ASP.NET 3.5 on IIS6 generating 401 “Unauthorised” responses followed by 200 “Ok” responses (as profiled by Fiddler). I’m aware of why this happening (integrated auth forcing the browser to resend credentials) but I’m looking for some thoughts on how to minimise or eradicate the situation. The application in question is running in the WAN with some users experiencing latency of up to 250ms so forcing a

Authorization in RESTful HTTP API, 401 WWW-Authenticate

不想你离开。 提交于 2019-11-29 02:10:28
问题 I'm creating a RESTful service to provide data to a web application. I have two related questions about this. 1. How to deal with unauthorized requests? I'm intending to respond to requests with the following codes: Is the resource open and found? 200 OK Do you need to be authenticated to access the resources? 401 Unauthorized Don't you have access to a category of resources? 403 Forbidden Do you have access to a category of resources, but not to this specific resource? 404 Not Found to

Return Mvc.JsonResult plus set Response.StatusCode

拜拜、爱过 提交于 2019-11-28 22:08:44
问题 Project: ASP MVC 4 running under .net 4.0 framework: When running an application under VS 2010 express (or deployed and running under IIS 7.5 on my local machine) the following (pseudocode) result from an action works as expected [HttpPost] public ActionResult PostWord(Model model) { .... Response.StatusCode = 400; Return new JsonResult { data = new {fieldName = "Word", error = "Not really a word!" } }; (and I have assigned ContentType and ContentEncoding properties of the JsonResult object,

Http Redirection code 3XX in python requests

风格不统一 提交于 2019-11-28 21:10:41
问题 I am trying to capture http status code 3XX/302 for a redirection url. But I cannot get it because it gives 200 status code. Here is the code: import requests r = requests.get('http://goo.gl/NZek5') print r.status_code I suppose this should issue either 301 or 302 because it redirects to another page. I had tried few redirecting urls (for e.g. http://fb.com ) but again it is issuing the 200. What should be done to capture the redirection code properly? 回答1: requests handles redirects for you

After a POST, should I do a 302 or a 303 redirect?

浪子不回头ぞ 提交于 2019-11-28 18:07:29
A common scenario for a web app is to redirect after a POST that modifies the database. Like redirecting to the newly created database object after the user creates it. It seems like most web apps use 302 redirects, but 303 seems to be the correct thing to do according to the specification if you want the url specified in the redirect to be fetched with GET. Technically, with a 302, the browser is supposed to fetch the specified url with the same method that the original url was fetched with, which would be POST. Most browsers don't do that though. 302 - http://www.w3.org/Protocols/rfc2616