Skip to content

Instantly share code, notes, and snippets.

@psihy
Last active December 14, 2015 01:08
Show Gist options
  • Save psihy/5003421 to your computer and use it in GitHub Desktop.
Save psihy/5003421 to your computer and use it in GitHub Desktop.
httpstatus
import std.algorithm, std.array, std.stdio, std.typecons;
immutable statusCode = [
tuple("100", "Continue"),
tuple("101", "Switching Protocols"),
tuple("102", "Processing"),
tuple("200", "OK"),
tuple("201", "Created"),
tuple("202", "Accepted"),
tuple("203", "Non-Authoritative Information"),
tuple("204", "No Content"),
tuple("205", "Reset Content"),
tuple("206", "Partial Content"),
tuple("207", "Multi-Status"),
tuple("208", "Already Reported"),
tuple("300", "Multiple Choices"),
tuple("301", "Moved Permanently"),
tuple("302", "Found"),
tuple("303", "See Other"),
tuple("304", "Not Modified"),
tuple("305", "Use Proxy"),
tuple("307", "Temporary Redirect"),
tuple("400", "Bad Request"),
tuple("401", "Unauthorized"),
tuple("402", "Payment Required"),
tuple("403", "Forbidden"),
tuple("404", "Not Found"),
tuple("405", "Method Not Allowed"),
tuple("406", "Not Acceptable"),
tuple("407", "Proxy Authentication Required"),
tuple("408", "Request Timeout"),
tuple("409", "Conflict"),
tuple("410", "Gone"),
tuple("411", "Length Required"),
tuple("412", "Precondition Failed"),
tuple("413", "Request Entity Too Large"),
tuple("414", "Request-URI Too Large"),
tuple("415", "Unsupported Media Type"),
tuple("416", "Request Range Not Satisfiable"),
tuple("417", "Expectation Failed"),
tuple("418", "I'm a teapot"),
tuple("422", "Unprocessable Entity"),
tuple("423", "Locked"),
tuple("424", "Failed Dependency"),
tuple("425", "No code"),
tuple("426", "Upgrade Required"),
tuple("428", "Precondition Required"),
tuple("429", "Too Many Requests"),
tuple("431", "Request Header Fields Too Large"),
tuple("449", "Retry with"),
tuple("500", "Internal Server Error"),
tuple("501", "Not Implemented"),
tuple("502", "Bad Gateway"),
tuple("503", "Service Unavailable"),
tuple("504", "Gateway Timeout"),
tuple("505", "HTTP Version Not Supported"),
tuple("506", "Variant Also Negotiates"),
tuple("507", "Insufficient Storage"),
tuple("509", "Bandwidth Limit Exceeded"),
tuple("510", "Not Extended"),
tuple("511", "Network Authentication Required")];
void main(string[] args) {
const result = (1 < args.length)?
statusCode.filter!(x => x[0].startsWith(args[1])).array:
statusCode;
foreach (x; result)
writeln(x[0], ": ", x[1]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment