5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineMode("http", function() {
15
function failFirstLine(stream, state) {
21
function start(stream, state) {
22
if (stream.match(/^HTTP\/\d\.\d/)) {
23
state.cur = responseStatusCode;
25
} else if (stream.match(/^[A-Z]+/) && /[ \t]/.test(stream.peek())) {
26
state.cur = requestPath;
29
return failFirstLine(stream, state);
33
function responseStatusCode(stream, state) {
34
var code = stream.match(/^\d+/);
35
if (!code) return failFirstLine(stream, state);
37
state.cur = responseStatusText;
38
var status = Number(code[0]);
39
if (status >= 100 && status < 200) {
40
return "positive informational";
41
} else if (status >= 200 && status < 300) {
42
return "positive success";
43
} else if (status >= 300 && status < 400) {
44
return "positive redirect";
45
} else if (status >= 400 && status < 500) {
46
return "negative client-error";
47
} else if (status >= 500 && status < 600) {
48
return "negative server-error";
54
function responseStatusText(stream, state) {
60
function requestPath(stream, state) {
61
stream.eatWhile(/\S/);
62
state.cur = requestProtocol;
66
function requestProtocol(stream, state) {
67
if (stream.match(/^HTTP\/\d\.\d$/)) {
71
return failFirstLine(stream, state);
75
function header(stream) {
76
if (stream.sol() && !stream.eat(/[ \t]/)) {
77
if (stream.match(/^.*?:/)) {
89
function body(stream) {
95
token: function(stream, state) {
97
if (cur != header && cur != body && stream.eatSpace()) return null;
98
return cur(stream, state);
101
blankLine: function(state) {
105
startState: function() {
111
CodeMirror.defineMIME("message/http", "http");