-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhttp-request-response.sublime-syntax
286 lines (253 loc) · 8.34 KB
/
http-request-response.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
scope: text.http-request-response
name: HTTP Request and Response
file_extensions:
- http
first_line_match: |-
(?x:
^
(?:
(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH)\ .+\ HTTP/\d(?:\.\d)?$
|
(?:HTTP/\d(?:\.\d)?\ \d{3}\ )
)
)
variables:
content_type_sep: (?=;|\r?$)
multipart_form_data_boundary: (?:^---+.*$)
http_version: (?:\bHTTP/\d(?:\.\d)?\b)
end_of_body: (?=^{{http_version}}[ ]\d{3})
end_of_headers: (?:^\r?$\n)
media_type_suffix_prefix: (?:[\w.-]+/[\w.-]+)
contexts:
prototype:
- match: '^##'
scope: punctuation.definition.comment.http-request-response
push:
- meta_scope: comment.line.syntax-test.http-request-response
- match: $\n?
set:
- match: ^
pop: true
main:
- match: ^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH)
scope: meta.http-verb.http-request-response keyword.operator.word.http-request-response
- match: '{{end_of_body}}'
push: response_begin
- include: http-protocol-version
- include: url_escape_char
- match: /
scope: meta.url punctuation.separator.path.directory.http-request-response
- match: \?
scope: punctuation.separator.sequence.querystring.http-request-response
push: querystring
- match: '[^&\s?/]+'
scope: meta.url.http-request-response
- match: $
set: http-headers
http-protocol-version:
- match: '{{http_version}}'
scope: constant.language.protocol-version.http-request-response
response_begin:
- include: http-protocol-version
- match: $
pop: true
- match: (?=[123])
set: [info, response_code]
- match: (?=4)
set: [warning, response_code]
- match: (?=5)
set: [error, response_code]
- include: response_code
warning:
- meta_scope: markup.warning.log
- match: ''
pop: true
error:
- meta_scope: markup.error.log
- match: ''
pop: true
info:
- meta_scope: markup.info.log
- match: ''
pop: true
response_code:
- match: \d+(\.\d+)?
scope: meta.http-status-code.http-request-response meta.number.integer.decimal.http-request-response constant.numeric.value.http-request-response
- match: \S.*$
scope: meta.http-response-status-text.http-request-response string.unquoted.http-request-response
pop: true
- match: $
pop: true
querystring:
- meta_content_scope: meta.querystring.http-request-response
- match: '[^&\s=]+'
scope: variable.parameter.http-request-response
- match: \&
scope: keyword.operator.querystring.and.http-request-response
- match: =
scope: keyword.operator.querystring.equals.http-request-response
push:
- match: '[^&\s%]+'
scope: string.unquoted.value.http-request-response
- include: url_escape_char
- match: ''
pop: true
- match: ''
pop: true
url_escape_char:
- match: (%)\h{2}
scope: meta.url constant.character.escape.url.html
captures:
1: punctuation.definition.escape.html
content-type:
- meta_content_scope: meta.headers.http-request-response
- match: (application/json|text/json|{{media_type_suffix_prefix}}\+json){{content_type_sep}}
set: [content-type-json, header-value]
- match: (application/xhtml\+xml|text/html){{content_type_sep}}
set: [content-type-html, header-value]
- match: (application/xml|text/xml|{{media_type_suffix_prefix}}\+xml){{content_type_sep}}
set: [content-type-xml, header-value]
- match: (application/x-www-form-urlencoded){{content_type_sep}}
set: [content-type-querystring, header-value]
- match: (multipart/form-data){{content_type_sep}}
set: [content-type-multipart-form-data, header-value]
- match: (application/javascript){{content_type_sep}}
set: [content-type-js, header-value]
- match: (text/css){{content_type_sep}}
set: [content-type-css, header-value]
- match: (?=\S.*{{content_type_sep}})
set: [content-type-plaintext, header-value]
http-headers:
- meta_content_scope: meta.headers.http-request-response
- match: (?i)^(Content-Type)(:)\s*
captures:
1: keyword.other.http-header.key.http-request-response
2: punctuation.separator.key-value.http-request-response
set: content-type
- match: ([^:]+)(:)\s*(\d+)$
captures:
1: keyword.other.http-header.key.http-request-response
2: punctuation.separator.key-value.http-request-response
3: meta.number.integer.decimal.http-request-response constant.numeric.value.http-request-response
- match: ([^:]+)(:)\s*
captures:
1: keyword.other.http-header.key.http-request-response
2: punctuation.separator.key-value.http-request-response
push: header-value
- match: '{{end_of_headers}}'
set: [body, embed_plain]
header-value:
- meta_scope: string.unquoted.http-header.value.http-request-response
- match: '[;,]'
scope: punctuation.separator.mapping.key-value.http-request-response
- match: \b([-\w]+)(=)
captures:
1: variable.parameter.http-request-response
2: keyword.operator.assignment.http-request-response
push: possible-number
- match: $
pop: true
possible-number:
- match: \b\d+(?!\.)\b
scope: meta.number.integer.decimal.http-request-response constant.numeric.value.http-request-response
pop: true
- match: ''
pop: true
content-type-json:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_json]
- include: http-headers
content-type-xml:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_xml]
- include: http-headers
content-type-html:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_html]
- include: http-headers
content-type-querystring:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_querystring]
- include: http-headers
content-type-multipart-form-data:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_multipart-form-data]
- include: http-headers
content-type-js:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_js]
- include: http-headers
content-type-css:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_css]
- include: http-headers
content-type-plaintext:
- meta_content_scope: meta.headers.http-request-response
- match: '{{end_of_headers}}'
set: [body, embed_plain]
- include: http-headers
multipart-form-data-boundary:
- match: '{{multipart_form_data_boundary}}'
scope: punctuation.separator.mapping.http-request-response
- include: http-headers
multipart-form-data:
- include: multipart-form-data-boundary
- include: http-headers
body:
- meta_content_scope: meta.body.http-request-response
- match: '{{end_of_body}}'
set: main
end_embed:
- match: '{{end_of_body}}'
pop: true
embed_json:
- include: end_embed
- match: ''
embed: scope:source.json
escape: '{{end_of_body}}'
embed_xml:
- include: end_embed
- match: ''
embed: scope:text.xml
escape: '{{end_of_body}}'
embed_html:
- include: end_embed
- match: ''
embed: scope:text.html.basic
escape: (?={{end_of_body}})
embed_js:
- include: end_embed
- match: ''
embed: scope:source.js
escape: '{{end_of_body}}'
embed_querystring:
- include: end_embed
- match: ''
embed: querystring
escape: '{{end_of_body}}'
embed_multipart-form-data:
- include: end_embed
- include: multipart-form-data-boundary
- match: ''
embed: multipart-form-data
escape: (?={{multipart_form_data_boundary}})|{{end_of_body}}
embed_plain:
- include: end_embed
- match: ''
embed: scope:text.plain
escape: '{{end_of_body}}'
embed_css:
- include: end_embed
- match: ''
embed: scope:source.css
escape: '{{end_of_body}}'