|
type HttpStatus = |
|
{ Code: string; Message: string } |
|
override self.ToString () = sprintf "%s %s" self.Code self.Message |
|
|
|
let httpStatus code message = { Code = code; Message = message } |
|
|
|
let httpStatusList =[ |
|
httpStatus "100" "Continue"; |
|
httpStatus "101" "Switching Protocols"; |
|
httpStatus "102" "Processing"; |
|
httpStatus "200" "OK"; |
|
httpStatus "201" "Created"; |
|
httpStatus "202" "Accepted"; |
|
httpStatus "203" "Non-Authoritative Information"; |
|
httpStatus "204" "No Content"; |
|
httpStatus "205" "Reset Content"; |
|
httpStatus "206" "Partial Content"; |
|
httpStatus "207" "Multi-Status"; |
|
httpStatus "208" "Already Reported"; |
|
httpStatus "300" "Multiple Choices"; |
|
httpStatus "301" "Moved Permanently"; |
|
httpStatus "302" "Found"; |
|
httpStatus "303" "See Other"; |
|
httpStatus "304" "Not Modified"; |
|
httpStatus "305" "Use Proxy"; |
|
httpStatus "307" "Temporary Redirect"; |
|
httpStatus "400" "Bad Request"; |
|
httpStatus "401" "Unauthorized"; |
|
httpStatus "402" "Payment Required"; |
|
httpStatus "403" "Forbidden"; |
|
httpStatus "404" "Not Found"; |
|
httpStatus "405" "Method Not Allowed"; |
|
httpStatus "406" "Not Acceptable"; |
|
httpStatus "407" "Proxy Authentication Required"; |
|
httpStatus "408" "Request Timeout"; |
|
httpStatus "409" "Conflict"; |
|
httpStatus "410" "Gone"; |
|
httpStatus "411" "Length Required"; |
|
httpStatus "412" "Precondition Failed"; |
|
httpStatus "413" "Request Entity Too Large"; |
|
httpStatus "414" "Request-URI Too Large"; |
|
httpStatus "415" "Unsupported Media Type"; |
|
httpStatus "416" "Request Range Not Satisfiable"; |
|
httpStatus "417" "Expectation Failed"; |
|
httpStatus "418" "I'm a teapot"; |
|
httpStatus "422" "Unprocessable Entity"; |
|
httpStatus "423" "Locked"; |
|
httpStatus "424" "Failed Dependency"; |
|
httpStatus "425" "No code"; |
|
httpStatus "426" "Upgrade Required"; |
|
httpStatus "428" "Precondition Required"; |
|
httpStatus "429" "Too Many Requests"; |
|
httpStatus "431" "Request Header Fields Too Large"; |
|
httpStatus "449" "Retry with"; |
|
httpStatus "500" "Internal Server Error"; |
|
httpStatus "501" "Not Implemented"; |
|
httpStatus "502" "Bad Gateway"; |
|
httpStatus "503" "Service Unavailable"; |
|
httpStatus "504" "Gateway Timeout"; |
|
httpStatus "505" "HTTP Version Not Supported"; |
|
httpStatus "506" "Variant Also Negotiates"; |
|
httpStatus "507" "Insufficient Storage"; |
|
httpStatus "509" "Bandwidth Limit Exceeded"; |
|
httpStatus "510" "Not Extended"; |
|
httpStatus "511" "Network Authentication Required" |
|
] |
|
|
|
let (|MatchStatus|_|) key status = |
|
if status.Code.Contains (key) || status.Message.Contains (key) |
|
then |
|
Some (status) |
|
else |
|
None |
|
let showStatus key = List.iter (function | MatchStatus key status -> printfn "%s" (status.ToString ()) | _ -> ()) httpStatusList |
|
|
|
[<EntryPoint>] |
|
let main args = |
|
if args.Length <> 1 then showStatus "" |
|
else showStatus args.[0] |
|
0 |