Custom Http Error Status
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers
Custom Http Status Codes
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x custom http status codes c# Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it
Custom Http Error Pages
only takes a minute: Sign up Can we create custom HTTP Status codes? up vote 44 down vote favorite 23 I have a REST and WCF service and want to send a custom status code based on the operation. http error status code 503 Example when some validation fails then i want to send HTTP 444 and when authorization fails i want to send HTTP 455 The question is how do we have it validated for both SOAP and REST web services. On the client how does the error code act because when you send a HTTP 400/500 from a WCF Service (using SOAP) an exception is throw on the client showing the status code. Now if i send a new custom status code http error status 204 how does the client handle this? c# asp.net wcf http wcf-rest share|improve this question asked Nov 3 '11 at 14:28 Rajesh 5,82031126 2 Is this a service you're exposing to the world, or do you control all the clients too? –Rup Nov 3 '11 at 14:59 add a comment| 4 Answers 4 active oldest votes up vote 61 down vote Yes, as long as you respect the class -- that is, 2xx for success, 4xx for Client error, etc. So you can return custom 4XX error codes (preferably those that are unassigned) for your own application's error conditions. To quote from RFC 2616: "HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes, though such understanding is obviously desirable. However, applications MUST understand the class of any status code, as indicated by the first digit, and treat any unrecognized response as being equivalent to the x00 status code of that class, with the exception that an unrecognized response MUST NOT be cached. For example, if an unrecognized status code of 431 is received by the client, it can safely assume that there was something wrong with its request and treat the response as if it had received a 400 status code." share|improve this answer answered Aug 8 '12 at 19:02 ChrisNY 1,2541313 1 Don't use unregistered status codes, except for testing. –Julian Reschke Feb 27 '14
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn
Http Error Status 0
more about hiring developers or posting ads with us Programmers Questions Tags Users Badges Unanswered http error status 401 Ask Question _ Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join
Http Error Status 502 Bad Gateway
them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Should I make up my own http://stackoverflow.com/questions/7996569/can-we-create-custom-http-status-codes HTTP status codes? (a la Twitter 420: Enhance Your Calm) up vote 16 down vote favorite 2 I'm currently implementing an HTTP API, my first ever. I've been spending a lot of time looking at the Wikipedia page for HTTP status codes, because I'm determined to implement the right codes for the right situations. Listed on that page is a code with number 420, which is a custom code that Twitter used to use for rate http://programmers.stackexchange.com/questions/218080/should-i-make-up-my-own-http-status-codes-a-la-twitter-420-enhance-your-calm limiting. There is already a code for rate limiting, though. It's 429. This led me to wonder why they would set a custom one, when there is already a use case. Is that just being cute? And if so, then which circumstances would make it acceptable to return a different status code, and what, if any problems may clients have with it? I read somewhere that Mozilla doesn't implement the joke 418: I’m a teapot response, which makes me think that clients choose which status codes they implement. If that's true, then I can imagine Twitter's funny little enhance your calm code being problematic. Unless I'm mistaken, and we can appropriate any code number to mean whatever we like, and that only convention dictates that 404 means not found, and 429 means take it easy. api-design http share|improve this question edited Nov 11 '13 at 3:15 Michael Hampton 2,1431915 asked Nov 10 '13 at 23:47 Max Bucknell 18815 migrated from serverfault.com Nov 11 '13 at 0:33 This question came from our site for system and network administrators. add a comment| 2 Answers 2 active oldest votes up vote 25 down vote accepted The whole of the Internet is built on conventions. We call them RFCs. While nobody will come and arrest you if you violate an RFC, you do run the risk that you
sections of messages Error, Forward and redirection responses may be used to contain human-readable diagnostic information. Success 2xx These https://www.w3.org/Protocols/HTTP/HTRESP.html codes indicate success. The body section if present is the object returned by the request. It is a MIME format object. It is in MIME format, and may only be in text/plain, text/html or one fo the formats specified as acceptable in the request. OK 200 The request was fulfilled. CREATED 201 Following a POST command, this indicates http error success, but the textual part of the response line indicates the URI by which the newly created document should be known. Accepted 202 The request has been accepted for processing, but the processing has not been completed. The request may or may not eventually be acted upon, as it may be disallowed when processing actually takes place. there http error status is no facility for status returns from asynchronous operations such as this. Partial Information 203 When received in the response to a GET command, this indicates that the returned metainformation is not a definitive set of the object from a server with a copy of the object, but is from a private overlaid web. This may include annotation information about the object, for example. No Response 204 Server has received the request but there is no information to send back, and the client should stay in the same document view. This is mainly to allow input for scripts without changing the document at the same time. Error 4xx, 5xx The 4xx codes are intended for cases in which the client seems to have erred, and the 5xx codes for the cases in which the server is aware that the server has erred. It is impossible to distinguish these cases in general, so the difference is only informational. The body section may contain a document describing the error in human readable form. The documen