Skip to content

Instantly share code, notes, and snippets.

@kos59125
Forked from Gab-km/HttpStatus.fs
Last active December 14, 2015 00:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kos59125/5003321 to your computer and use it in GitHub Desktop.
Save kos59125/5003321 to your computer and use it in GitHub Desktop.
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

一般的な Web Programmer ならば、HTTP Status code はすべて暗記していると聞きました。

しかし、僕は初心者なので、なかなか覚えきれていないので、HTTPのステータスコードをさがすのに便利なツールを用意しました。

HttpStatus.fs です。インストール方法は 適当にコンパイルしてください。

See also

httpstatus コマンドで、HTTP のステータスコードをすばやくしらべる! - tokuhirom's blog.

Big Sky :: httpstatus コマンドで、HTTP のステータスコードをすばやくしらべる!

httpstatus コマンドで、HTTP のステータスコードをすばやくしらべる! - ( ꒪⌓꒪) ゆるよろ日記

httpstatusコマンドで、HTTPのステータスコードをすばやくしらべる! - YAMAGUCHI::weblog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment