http-status-codes

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

。_饼干妹妹 提交于 2019-11-30 04:37:54
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 subsequent request can have a noticeable impact on page load time, particularly when there are a number of

Which HTTP status codes are cacheable?

ぃ、小莉子 提交于 2019-11-30 04:23:35
问题 As stated in the title, which HTTP status codes are acceptable to cache as a browser? I did a quick search and did not find an authoritative answer. Originally I thought it may only be 200 OK responses, but I couldn't find any evidence to support that thought. 回答1: Short answer According to the RFC 7231, the current reference for content and semantics of the HTTP/1.1 protocol, the following HTTP status codes are defined as cacheable unless otherwise indicated by the method definition or

HTTP POST response Location header when creating multiple resources

不问归期 提交于 2019-11-30 03:04:22
问题 The HTTP/1.1 standard states that if a POST operation results in the creation of a resource, then the response should include a Location header with the address of the new resource. If a resource has been created on the origin server, the response SHOULD be 201 (Created) and contain an entity which describes the status of the request and refers to the new resource, and a Location header (see section 14.30). and in section 14.30, For 201 (Created) responses, the Location is that of the new

Return Mvc.JsonResult plus set Response.StatusCode

瘦欲@ 提交于 2019-11-30 01:18:22
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, with no difference in behaviour) When the deployable is moved onto a web host (using IIS 7), firebug is

Ruby-on-Rails: How to get rid of “you are being redirected” page

纵然是瞬间 提交于 2019-11-30 00:42:53
问题 I am overriding Devise's failure response so that I can set a 401 status code. However, when the user fails to sign in, they are redirected to a page with a "you are being redirected" link. If I remove this :status => 401 from the redirect it works fine. class CustomFailure < Devise::FailureApp def redirect_url new_user_session_url(:subdomain => 'secure') end def respond if http_auth? http_auth else store_location! flash[:alert] = i18n_message unless flash[:notice] redirect_to redirect_url,

Http Redirection code 3XX in python requests

眉间皱痕 提交于 2019-11-30 00:12:01
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? requests handles redirects for you , see redirection and history . Set allow_redirects=False if you don't want requests to handle redirections,

Convention for HTTP response header to notify clients of deprecated API

倾然丶 夕夏残阳落幕 提交于 2019-11-29 22:35:09
I'm upgrading our REST API endpoints and I want to notify clients when they are calling the to-be-deprecated endpoint. What header should I use in the response with a message along the lines of "This API version is being deprecated, please consult the latest documentation to update your endpoints" I would not change anything in the status code to be backward compatible. I would add a "Warning" header in the response : Warning: 299 - "Deprecated API" You can also specify the "-" with the "Agent" that emits the warning, and be more explicit in the warn-text : Warning: 299 api.blazingFrog.com

How to check for an HTTP status code of 401?

浪子不回头ぞ 提交于 2019-11-29 18:13:25
In one of the answers that I have received here , I encountered a problem of not knowing how to pass automatically through "Google App Engines" my ID and a password to a website, on which I am a registered user and have an account. A suggestion was given to me to "check for an HTTP status code of 401, "authorization required", and provide the kind of HTTP authorization (basic, digest, whatever) that the site is asking for". I don't know how to check for status code. Can anyone, please, tell me how to do it? +++++++++++++++++++++++++++++++++ Additional Information: If I use this way in Google

What's the deal with HTTP status code 308?

岁酱吖の 提交于 2019-11-29 16:44:57
问题 An IETF RFC draft The Hypertext Transfer Protocol (HTTP) Status Code 308 (Permanent Redirect) defines HTTP status 308 as Permanent Redirect . It should, of course, be noted that this is a draft document and contains in its document header the text "Expires: September 27, 2012", which I presume would mean it should be considered invalid now, but I'm not familiar with IETF's processes and so don't feel confident about this. The Wikipedia article List of HTTP status codes uses this definition of

Is the use of Location header in HTTP 202 response RFC-compliant?

痴心易碎 提交于 2019-11-29 16:38:20
问题 I have a great conceptual discussion with my coworkers about the use of Location header in 202 Accepted response. The story began analyzing the behavior of PHP header() function from here. The interesting excerpt: The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set. They didn't include 202 status code in this default