PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.15.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.15.9
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / assets / lib / codemirror / mode / http / http.js

http.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.15.9, at assets/lib/codemirror/mode/http/http.js

99 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 CodeMirror.defineMode("http", function() {
2 function failFirstLine(stream, state) {
3 stream.skipToEnd();
4 state.cur = header;
5 return "error";
6 }
7
8 function start(stream, state) {
9 if (stream.match(/^HTTP\/\d\.\d/)) {
10 state.cur = responseStatusCode;
11 return "keyword";
12 } else if (stream.match(/^[A-Z]+/) && /[ \t]/.test(stream.peek())) {
13 state.cur = requestPath;
14 return "keyword";
15 } else {
16 return failFirstLine(stream, state);
17 }
18 }
19
20 function responseStatusCode(stream, state) {
21 var code = stream.match(/^\d+/);
22 if (!code) return failFirstLine(stream, state);
23
24 state.cur = responseStatusText;
25 var status = Number(code[0]);
26 if (status >= 100 && status < 200) {
27 return "positive informational";
28 } else if (status >= 200 && status < 300) {
29 return "positive success";
30 } else if (status >= 300 && status < 400) {
31 return "positive redirect";
32 } else if (status >= 400 && status < 500) {
33 return "negative client-error";
34 } else if (status >= 500 && status < 600) {
35 return "negative server-error";
36 } else {
37 return "error";
38 }
39 }
40
41 function responseStatusText(stream, state) {
42 stream.skipToEnd();
43 state.cur = header;
44 return null;
45 }
46
47 function requestPath(stream, state) {
48 stream.eatWhile(/\S/);
49 state.cur = requestProtocol;
50 return "string-2";
51 }
52
53 function requestProtocol(stream, state) {
54 if (stream.match(/^HTTP\/\d\.\d$/)) {
55 state.cur = header;
56 return "keyword";
57 } else {
58 return failFirstLine(stream, state);
59 }
60 }
61
62 function header(stream) {
63 if (stream.sol() && !stream.eat(/[ \t]/)) {
64 if (stream.match(/^.*?:/)) {
65 return "atom";
66 } else {
67 stream.skipToEnd();
68 return "error";
69 }
70 } else {
71 stream.skipToEnd();
72 return "string";
73 }
74 }
75
76 function body(stream) {
77 stream.skipToEnd();
78 return null;
79 }
80
81 return {
82 token: function(stream, state) {
83 var cur = state.cur;
84 if (cur != header && cur != body && stream.eatSpace()) return null;
85 return cur(stream, state);
86 },
87
88 blankLine: function(state) {
89 state.cur = body;
90 },
91
92 startState: function() {
93 return {cur: start};
94 }
95 };
96 });
97
98 CodeMirror.defineMIME("message/http", "http");
99