context: //
  //  Status.cs
  //
  //  Author:
  //       Simon Mika <smika@hx.se>
  //
  //  Copyright (c) 2013 Simon Mika
  //
  //  This program is free software: you can redistribute it and/or modify
  //  it under the terms of the GNU Lesser General Public License as published by
  //  the Free Software Foundation, either version 3 of the License, or
  //  (at your option) any later version.
  //
  //  This program is distributed in the hope that it will be useful,
  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  //  GNU Lesser General Public License for more details.
  //
  //  You should have received a copy of the GNU Lesser General Public License
  //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  using System;
  using Kean;
  using Kean.Extension;
  
  namespace Aser.Http
  {
  	public struct Status
  	{
  		int code;
  		public bool Success
  		{
  			get { return this.code < 400; }
  		}
  		public override string ToString()
  		{
  			return this;
  		}
  		#region Casts
  		public static implicit operator int(Status status)
  		{
  			return status.code; 
  		}
  		public static explicit operator Status(int status)
  		{
  			return new Status() { code = status }; 
  		}
  		public static implicit operator string(Status status)
  		{
  			string name;
  			switch (status.code)
  			{
  				case 100:
  					name = "Continue";
  					break;
  				case 101:
  					name = "Switching Protocols";
  					break;
  				case 200:
  					name = "OK";
  					break;
  				case 201:
  					name = "Created";
  					break;
  				case 202:
  					name = "Accepted";
  					break;
  				case 203:
  					name = "Non-Authorative Information";
  					break;
  				case 204:
  					name = "No Content";
  					break;
  				case 205:
  					name = "Reset Content";
  					break;
  				case 206:
  					name = "Partial Content";
  					break;
  				case 300:
  					name = "Multiple Choices";
  					break;
  				case 301:
  					name = "Moved Permanently";
  					break;
  				case 303:
  					name = "See Other";
  					break;
  				case 304:
  					name = "Not Modified";
  					break;
  				case 305:
  					name = "Use Proxy";
  					break;
  				case 307:
  					name = "Temporary Redirect";
  					break;
  				case 308:
  					name = "Permanent Redirect";
  					break;
  				case 400:
  					name = "Bad Request";
  					break;
  				case 401:
  					name = "Unauthorized";
  					break;
  				case 402:
  					name = "Payment Required";
  					break;
  				case 403:
  					name = "Forbidden";
  					break;
  				case 404:
  					name = "Not Found";
  					break;
  				case 405:
  					name = "Method Not Allowed";
  					break;
  				case 406:
  					name = "Not Acceptable";
  					break;
  				case 407:
  					name = "Proxy Authentication Required";
  					break;
  				case 408:
  					name = "Request Timeout";
  					break;
  				case 409:
  					name = "Conflict";
  					break;
  				case 410:
  					name = "Gone";
  					break;
  				case 411:
  					name = "Length Required";
  					break;
  				case 412:
  					name = "Precondition Failed";
  					break;
  				case 413:
  					name = "Request Entity Too Large";
  					break;
  				case 414:
  					name = "Request-URI Too Long";
  					break;
  				case 415:
  					name = "Unsupported Media Type";
  					break;
  				case 416:
  					name = "Requested Range Not Satifiable";
  					break;
  				case 417:
  					name = "Expectation Failed";
  					break;
  				case 419:
  					name = "Authentication Timeout";
  					break;
  				case 426:
  					name = "Upgrade Required";
  					break;
  				case 428:
  					name = "Precondition Failed";
  					break;
  				case 429:
  					name = "Too Many Requests";
  					break;
  				case 431:
  					name = "Request Header Fields Too Large";
  					break;
  				case 500:
  					name = "Internal Server Error";
  					break;
  				case 501:
  					name = "Not Implemented";
  					break;
  				case 502:
  					name = "Bad Gateway";
  					break;
  				case 503:
  					name = "Service Unavailable";
  					break;
  				case 504:
  					name = "Gateway Timeout";
  					break;
  				case 505:
  					name = "HttpVersionNotSupported";
  					break;
  				case 506:
  					name = "VariantAlsoNegotiates";
  					break;
  				case 507:
  					name = "Insufficent Storage";
  					break;
  				case 508:
  					name = "Loop Detected";
  					break;
  				case 509:
  					name = "Band Width Limit Exceeded";
  					break;
  				case 510:
  					name = "Not Extended";
  					break;
  				case 511:
  					name = "Network Authetication Required";
  					break;
  				default:
  					name = "Unknown Status";
  					break;
  			}
  
gt: 			return status.code + " " + name; 