http-status-codes

Can an HTTP OPTIONS request return a 204 or should it always return 200?

£可爱£侵袭症+ 提交于 2020-01-11 04:42:07
问题 According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2 the only response ever mentioned regarding an HTTP OPTIONS request is a 200. However, there seem to be cases such as when the content-length is 0 that a 204 would be more appropriate. Is it appropriate for an HTTP OPTIONS request to return a 204? 回答1: Yes, it can return 204. Or 400. Or 404. There is no general restriction as to what status codes a method can return. Also note that it's time to stop looking at RFC 2616.

Proper use of HTTP status codes in a “validation” server

谁说胖子不能爱 提交于 2020-01-09 12:51:10
问题 Among the data my application sends to a third-party SOA server are complex XMLs. The server owner does provide the XML schemas ( .xsd ) and, since the server rejects invalid XMLs with a meaningless message, I need to validate them locally before sending. I could use a stand-alone XML schema validator but they are slow, mainly because of the time required to parse the schema files. So I wrote my own schema validator (in Java, if that matters) in the form of an HTTP Server which caches the

ASP.NET Boilerplate available list of exceptions and returned HTTP Status Codes

不羁岁月 提交于 2020-01-07 04:45:27
问题 I am building an API with ASP.NET Boilerplate and they abstract out the error handling and returning of the HTTP Status Codes. I have looked through the documentation and it only mentions UserFriendlyException and AbpValidationException. What are the other available exceptions I can throw with ASP.NET Boilerplate and its corresponding HTTP response codes that it returns? 回答1: Below are the exceptions and the correspondings status code according to the GetStatusCode() method: Abp.AbpException

How to set http status code in GraphQL

末鹿安然 提交于 2020-01-04 05:38:09
问题 I want to set an http status code in my GraphQL authentication query, depending on if auth attempt was successful (200), unauthorised (401) or missing parameters (422). I am using Koa and Apollo and have configured my server like so: const graphqlKoaMiddleware = graphqlKoa(ctx => { return ({ schema, formatError: (err) => ({ message: err.message, status: err.status }), context: { stationConnector: new StationConnector(), passengerTypeConnector: new PassengerTypeConnector(), authConnector: new

Laravel won't obey status code

≯℡__Kan透↙ 提交于 2020-01-03 18:00:53
问题 I just can't understand, and don't know where else to look, as the response status code of the following code is always 200, even if I set it to 400 in the main Response class. class Api_Controller extends Base_Controller { public function __construct() { parent::__construct(); //header("HTTP/1.0 404 Not Found"); ##> This works //die(); $test = array('1' => '2'); die(Response::json($test, 400)); } What am I missing? I'm not using any extended class, just the default... Update This is the

Redirecting to HTTP error documents without changing the request URL

帅比萌擦擦* 提交于 2020-01-03 17:31:55
问题 I'm trying to show an HTTP error document from a PHP page, but I would like the original URL to remain in the address bar to prevent search engine crawlers getting confused and to allow for reloading of the page in case it's a temporary issue. I made a redirect function in PHP which goes a bit like this: public static function Redirect($url, $code = '303 See Other') { header('HTTP/1.1 ' . $code); header('Location: ' . $url); exit(0); } If I want to display an error document, such as 403

Is HTTP 303 acceptable for other HTTP methods?

筅森魡賤 提交于 2020-01-03 13:35:00
问题 RESTful Web Services encourages the use of HTTP 303 to redirect clients to the canonical representation of a resource. It only discusses topic in the context of HTTP GET . Does this apply to other HTTP methods as well? If a client attempts a HTTP PUT or DELETE to a non-canonical URI, is it acceptable (and/or recommended) to return HTTP 303? What is the best practice and why? 回答1: This status code is generally applicable to any HTTP method. It is primarily used to allow the output of a POST

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

喜你入骨 提交于 2020-01-02 10:01:49
问题 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

Java library to map HTTP status code to description? [closed]

为君一笑 提交于 2020-01-02 01:06:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I'm in the situation where I'm writing custom error pages for a webapp (primarily to reduce information disclosure from the servlet container's default error pages). Since I need an error page for each error status code, I'm going to have to have a sensible response for each code. As far as I can tell, these

HTTP status code for limited collection?

梦想与她 提交于 2020-01-01 10:05:05
问题 I have a restful service where one of the collections is limited (for UX reasons). In this case it has a cap of 25 items. If that is exceeded resources must be deleted before more can be added. As an example if a client submits: POST http://somesite.com/api/v2/stuff {"cool":"stuff"} and there are < 25 things in stuff: 200 OK if > 25 things in stuff: ??? DELETE http://somesite.com/api/v2/stuff/:id POST http://somesite.com/api/v2/stuff {"cool":"stuff"} 200 OK What is the best code for this?