http-status-codes

understanding REST Response and HTTP status code

南笙酒味 提交于 2019-12-11 13:12:48
问题 I wanted to know how I should respond in my REST API. Valid Example: http://blah.com/api/v1/dosomething/123 The above is a valid request and currently I have a HTTP Status of 200 with a JSON response { "dosomething": { "status": "OK", "results": "123" } } Now my question is, if the parameter passed is not valid ( I'm expecting a string of whole numbers ), do I return a HTTP Response of 200 and pass the error status back in the JSON response or should I pass something like a HTTP 400 response

How to properly send 406 status code?

余生颓废 提交于 2019-12-11 06:38:54
问题 I'm developing a RESTful API service which initially will only be accepting and responding in JSON format. I want to follow standards and in case of requester's Accept header was different than JSON I want to respond with 406 HTTP status code to inform the requester I cannot output data in other format. According to W3 I "SHOULD include an entity containing a list of available entity characteristics and location(s) from which the user or user agent can choose the one most appropriate" in my

Get http-statuscode without body using cURL?

一世执手 提交于 2019-12-11 02:40:30
问题 I want to parse a lot of URLs to only get their status codes. So what I did is: $handle = curl_init($url -> loc); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_HEADER , true); // we want headers curl_setopt($handle, CURLOPT_NOBODY , true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($handle); $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); curl_close($handle); But as soon as the "nobody"-option is set to true, the returned

Index.php as custom error page

邮差的信 提交于 2019-12-11 01:06:29
问题 I'm using Apache 2.2.X and PHP 5.2.X (installed as Apache module) to build a new website and I would like to read your suggestions about how I'm trying to handle server errors. I was thinking about using the same file of my homepage (/index.php) to show custom error messages. This is my .htaccess setup: ErrorDocument 400 /index.php?error=400 ErrorDocument 401 /index.php?error=401 ErrorDocument 403 /index.php?error=403 ErrorDocument 404 /index.php?error=404 ErrorDocument 500 /index.php?error

HTTP status code = 0 (iPhone) (objective c)

橙三吉。 提交于 2019-12-11 00:38:07
问题 I want to ask about the iPhone application objective C problem. I wrote a program to store the cookies and pass to another URL to retrieve the cookies. However, I found that one of the return status code is 0. The content of the html is empty. Can any one help me? The following is my code. // create a new mutable url NSMutableURLRequest *request_get2 = [[[NSMutableURLRequest alloc] init] autorelease]; [request_get2 setURL:[NSURL URLWithString:@"http://www.example.com"]]; [request_get2

When to show 404 versus 301?

痴心易碎 提交于 2019-12-10 21:58:21
问题 So I've been noticing some strange results in how google peruses our site. One issue is that a url such as this: http://example.com/randomstring is showing up on google with all of the data of http://example.com/ So in my mind there are two solutions. One is to add a 301 redirect whenever someone visits a sub-url of the main one, and redirect them to the parent URL, or just give a 404, with a nice message saying, "Maybe you meant parent-url ". Thoughts? I'm pretty sure I know where I want to

What HTTP status code use when displaying alternative error page for old browsers?

女生的网名这么多〃 提交于 2019-12-10 19:28:57
问题 I have a website that heavily uses CSS3 and some HTML5 modern features. So it doesn't work in IE7 or lower and looks very bad. The decision was that we will not support these old browsers as it is too much work for very few users. Instead of displaying regular page, they see special error/warning page, where they informed about why they see it and that they should install newer browser. This works fine. But my question is - what HTTP status code should I send with this page ? Does it matter ?

How can I reliably detect if Flash was the originator of a request to a service?

爷,独闯天下 提交于 2019-12-10 19:14:18
问题 I need to be able to detect if flash was the originator of a request to an ASP.NET service. The reason being that Flash is unable to process SOAP messages when the response status code is something other than 200. However, I allow exception to bubble up through our SOAP web services and as a result the status code for a SOAP server fault is 500. Before Flash 10 I was able to check the referrer property and if it ended in .SWF I changed the status code to 200 so that our Flex application could

Page not rendered when sending statuscode 500 to the client

我的未来我决定 提交于 2019-12-10 19:09:00
问题 I have a page (generic handler) on which I want to return the status code 500 to the client to indicate that something is wrong. I do it like this: Response.StatusCode = 500; Response.StatusDescription = "Internal Server Error"; And at the same time I render a friendly message telling the user that something went wrong. But instead of seing my message, I get the default IIS message saying something like this: Server Error 500 - Internal server error. There is a problem with the resource you

Is 202 Accepted appropriate when a resource awaits email confirmation/activation?

只谈情不闲聊 提交于 2019-12-10 17:35:20
问题 For a REST API I'm developing, a client is able to register a company, which subsequently needs confirmation/activation through email. After the following example request is received, an email is sent with an activation link in it, to activate the account. POST /companies HTTP/1.1 <company> <name>CoolCompany</name> <email>coolcompany@example.com</email> </company> If the above request was successful (valid data, email successfully sent), the company resource is saved in the database, but will