Skip to content

Instantly share code, notes, and snippets.

@teramako
Last active December 14, 2015 00:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teramako/5002567 to your computer and use it in GitHub Desktop.
Save teramako/5002567 to your computer and use it in GitHub Desktop.
[Vimperator]httpstatus コマンドで、HTTP のステータスコードをすばやくしらべる! 一般的な Web Programmer ならば、HTTP Status code はすべて暗記していると聞きました。 しかし、僕はWeb Programmerではないので、なかなか覚えきれていないので、HTTPのステータスコードをさがすのに便利なツールを用意しました。
/**
* @see http://blog.64p.org/entry/2013/02/21/121830
* @see http://mattn.kaoriya.net/software/vim/20130221123856.htm
* @see http://yuroyoro.hatenablog.com/entry/2013/02/21/144004
* @see http://ymotongpoo.hatenablog.com/entry/2013/02/21/160646
* @see http://d.hatena.ne.jp/syohex/20130221/1361423585
* @see http://blog.livedoor.jp/dankogai/archives/51855038.html
* @see http://d.hatena.ne.jp/hasegawayosuke/20130221
* @see https://gist.github.com/tk0miya/5002917
* @see http://app2641.hatenablog.com/entry/2013/02/21/161928
* @see https://gist.github.com/fumiyas/5003062
* @see https://gist.github.com/Gab-km/5003050
* @see http://masahito.hatenablog.com/entry/2013/02/21/180506
*/
var httpstatuses = {
100: 'Continue',
101: 'Switching Protocols',
102: 'Processing', // RFC 2518 (WebDAV)
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-Authoritative Information',
204: 'No Content',
205: 'Reset Content',
206: 'Partial Content',
207: 'Multi-Status', // RFC 2518 (WebDAV)
208: 'Already Reported', // RFC 5842
300: 'Multiple Choices',
301: 'Moved Permanently',
302: 'Found',
303: 'See Other',
304: 'Not Modified',
305: 'Use Proxy',
307: 'Temporary Redirect',
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Timeout',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Request Entity Too Large',
414: 'Request-URI Too Large',
415: 'Unsupported Media Type',
416: 'Request Range Not Satisfiable',
417: 'Expectation Failed',
418: 'I\'m a teapot', // RFC 2324
422: 'Unprocessable Entity', // RFC 2518 (WebDAV)
423: 'Locked', // RFC 2518 (WebDAV)
424: 'Failed Dependency', // RFC 2518 (WebDAV)
425: 'No code', // WebDAV Advanced Collections
426: 'Upgrade Required', // RFC 2817
428: 'Precondition Required',
429: 'Too Many Requests',
431: 'Request Header Fields Too Large',
449: 'Retry with', // unofficial Microsoft
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
506: 'Variant Also Negotiates', // RFC 2295
507: 'Insufficient Storage', // RFC 2518 (WebDAV)
509: 'Bandwidth Limit Exceeded', // unofficial
510: 'Not Extended', // RFC 2774
511: 'Network Authentication Required',
// From https://github.com/joho/7XX-rfc
701: 'Meh',
702: 'Emacs',
703: 'Explosion',
710: 'PHP',
711: 'Convenience Store',
712: 'NoSQL',
719: 'I am not a teapot',
720: 'Unpossible',
721: 'Known Unknowns',
722: 'Unknown Unknowns',
723: 'Tricky',
724: 'This line should be unreachable',
725: 'It works on my machine',
726: 'It\'s a feature, not a bug',
727: '32 bits is plenty',
731: 'Fucking Rubygems',
732: 'Fucking Unic💙de',
733: 'Fucking Deadlocks',
734: 'Fucking Deferreds',
735: 'Fucking IE',
736: 'Fucking Race Conditions',
737: 'FuckThreadsing',
738: 'Fucking Bundler',
739: 'Fucking Windows',
740: 'Computer says no',
741: 'Compiling',
742: 'A kitten dies',
743: 'I thought I knew regular expressions',
744: 'Y U NO write integration tests?',
745: 'I don\'t always test my code, but when I do I do it in production',
746: 'Missed Ballmer Peak',
747: 'Motherfucking Snakes on the Motherfucking Plane',
748: 'Confounded by Ponies',
749: 'Reserved for Chuck Norris',
750: 'Didn\'t bother to compile it',
753: 'Syntax Error',
754: 'Too many semi-colons',
755: 'Not enough semi-colons',
759: 'Unexpected T_PAAMAYIM_NEKUDOTAYIM',
761: 'Hungover',
762: 'Stoned',
763: 'Under-Caffeinated',
764: 'Over-Caffeinated',
765: 'Railscamp',
766: 'Sober',
767: 'Drunk',
768: 'Accidentally Took Sleeping Pills Instead Of Migraine Pills During Crunch Week',
769: 'Questionable Maturity Level',
771: 'Cached for too long',
772: 'Not cached long enough',
773: 'Not cached at all',
774: 'Why was this cached?',
776: 'Error on the Exception',
777: 'Coincidence',
778: 'Off By One Error',
779: 'Off By Too Many To Count Error',
780: 'Project owner not responding',
781: 'Operations',
782: 'QA',
783: 'It was a customer request, honestly',
784: 'Management, obviously',
785: 'TPS Cover Sheet not attached',
786: 'Try it now',
791: 'The Internet shut down due to copyright restrictions.',
792: 'Climate change driven catastrophic weather event',
793: 'Zombie Apocalypse',
794: 'Someone let PG near a REPL',
797: 'This is the last page of the Internet. Go back',
799: 'End of the world',
};
commands.addUserCommand(["httpstatus"], "show HTTP status text",
function (args) {
var arg = args.literalArg;
var data = [];
if (arg) {
if (arg in httpstatuses) {
data = [[arg, httpstatuses[arg]]];
} else if (/^[1-5]/.test(arg)) {
var reg = new RegExp("^" + arg);
data = [[code, httpstatuses[code]] for (code in httpstatuses) if (reg.test(code))];
} else {
var reg = new RegExp("^" + arg, "i");
data = [[code, httpstatuses[code]] for (code in httpstatuses) if (reg.test(httpstatuses[code]))];
}
} else {
data = [[code, httpstatuses[code]] for (code in httpstatuses)];
}
commandline.echo(template.table("HTTP STATUS", data));
}, {
literal: 0,
completer: function (context,args) {
context.anchor = false;
context.completions = [[code, httpstatuses[code]] for (code in httpstatuses)];
},
}, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment