http-status-codes

HTTP Status Code for External Dependency Error

北战南征 提交于 2019-12-09 07:43:35
问题 What is the correct HTTP status code to return when a server is having issues communicating with an external API? Say a client sends a valid request to my server A, A then queries server B's API in order to do something. However B's API is currently throwing 500's or is somehow unreachable, what status code should A return to the client? A 5* error doesn't seem correct because server A is functioning as it should, and a 4* error doesn't seem correct because the client is sending a valid

Create request with POST, which response codes 200 or 201 and content

感情迁移 提交于 2019-12-09 04:03:44
问题 Suppose I write a REST service whose intent is to add a new data item to a system. I plan to POST to http://myhost/serviceX/someResources Suppose that works, what response code should I use? And what content might I return. I'm looking at the definitions of HTTP response codes and see these possibilities: 200: Return an entity describing or containing the result of the action; 201: which means CREATED. Meaning *The request has been fulfilled and resulted in a new resource being created. The

Can AWS API Gateway cache invalidate specific entries based on the response content?

こ雲淡風輕ζ 提交于 2019-12-09 03:51:27
I have used AWS API Gateway with the endpoint as a lambda function. I have enabled the cache functionality provided by API Gateway, to reduce both response time & the number of calls forwarded to my lambda function. The lambda function queries another data store to return data. If data is not found, an asynchronous call is made to update the data store and "data not found" is returned to the caller. Now the API Gateway is even caching this result, which we do not want to happen. This results in the cache always returning "data not found" for its lifetime (1 hr TTL), even though data is updated

Faking Http Status Codes in IIS/.net for testing

眉间皱痕 提交于 2019-12-09 03:18:38
问题 This is quite an odd question, but I am trying to test the Web.Config settings for custom errors e.g.: <customErrors mode="On"/> <error statusCode="500" redirect="500.html"/> <error statusCode="500.13" redirect="500.13.html"/> </customErrors> Is there anyway I can create a page or intercept the request in the global.asax Application_BeginRequest method that can fake up a response to send to the browser i.e. setup a 500.13 HTTP error status which tells IIS to use the 500.13.html page defined

what should be HTTP status code for credentials Expired error/exception?

大城市里の小女人 提交于 2019-12-08 21:19:11
问题 I am developing RESTful APIs, I have implemented token-based authentication, where token digest is prepared using time-stamp. Now when request comes to API server, I am checking if the supplied time-stamp is invalid ( i.e. date-time from future/past is specified) then am throwing error message indicating that "future token detected" or "token has expired". I need to attach HTTP status code I am confused about which status code is suitable for this situation? I have gone through the status

What (if any) http status code is returned when a MIME type is missing?

女生的网名这么多〃 提交于 2019-12-08 19:39:39
问题 If a web server doesn't have a MIME type added for a file that a client tries to download, what (if any) http status code would be returned? It suggests here it could be 415, although the answer isn't definite: HTTP status code for unaccepted Content-Type in request 回答1: The answer is "415 Unsupported Media Type" if your question is "what is the correct status code for a request if its body is content-encoded in the media type the server cannot accept." RFC 2616 and draft-ietf-httpbis-p2

StrongLoop Loopback : How to customize HTTP response code and header

北慕城南 提交于 2019-12-08 19:06:50
问题 I'm looking for a way to customize StrongLoop LoopBack HTTP response code and headers. I would like to conform to some company business rules regarding REST API. Typical case is, for a model described in JSON, to have HTTP to respond to POST request with a code 201 + header Content-Location (instead of loopback's default response code 200 without Content-Location header). Is it possible to do that using LoopBack ? 回答1: Unfortunately the way to do this is a little difficult because LoopBack

How to let Apache send 500 in case of PHP error?

你说的曾经没有我的故事 提交于 2019-12-08 18:41:32
问题 I'm developing a PHP application that uses HTTP response codes for communication as well as response bodies. So this is a typical scenario in the PHP code: try { doSomething(); } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); } ... and the typical code in clients looks like: switch(responseCode) { case 200 : // all fine // .... case 500 : // trouble! } This is cool, as long as every error is well caught in PHP code. The problem: If, for any reason in the php code occures

Getting a HttpStatusCode of 0

耗尽温柔 提交于 2019-12-08 15:55:33
问题 Why am I getting a HttpStatusCode of 0 if I point the service my client is connecting to to a bad URL. My statusCodeAsInt is showing up as a 0. Why is it not showing up as a 404 and being handled? IRestResponse response = client.Execute(restReq); HttpStatusCode statusCode = response.StatusCode; var statusCodeAsInt = (int) statusCode; if (statusCodeAsInt >= 500) { throw new InvalidOperationException("A server error occurred: " + response.ErrorMessage, response.ErrorException); } if

What HTTP response status code to use for unrelated redirects of random chance?

好久不见. 提交于 2019-12-08 14:19:46
问题 My website has a 1% random chance of redirecting visitors to this YouTube video. The server currently sends the good-old 302, but I want it to have better semantics. I don't know if the redirect is permanent or temporary. It's permanent in the sense that people always have a 1% chance of being redirected, and it's temporary in the sense that people don't get redirected every single time. None of the current 3xx response status codes match my website's behavior. HTTP 3xx redirects (source: