-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,46 @@ | ||
(function (Prism) { | ||
Prism.languages.http = { | ||
'request-line': { | ||
pattern: /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m, | ||
pattern: /^(?:GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH|PRI|SEARCH)\s(?:https?:\/\/|\/)\S*\sHTTP\/[0-9.]+/m, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
RunDevelopment
Member
|
||
inside: { | ||
// HTTP Verb | ||
'property': /^(?:POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/, | ||
// Path or query argument | ||
'attr-name': /:\w+/ | ||
// HTTP Method | ||
'method': { | ||
pattern: /^[A-Z]+\b/, | ||
alias: 'property' | ||
}, | ||
// Request Target e.g. http://example.com, /path/to/file | ||
'request-target': { | ||
pattern: /^(\s)(?:https?:\/\/|\/)\S*(?=\s)/, | ||
lookbehind: true, | ||
alias: 'url' | ||
}, | ||
// HTTP Version | ||
'http-version': { | ||
pattern: /^(\s)HTTP\/[0-9.]+/, | ||
lookbehind: true, | ||
alias: 'property' | ||
}, | ||
} | ||
}, | ||
'response-status': { | ||
pattern: /^HTTP\/1.[01] \d.*/m, | ||
pattern: /^HTTP\/[0-9.]+ \d+ .+/m, | ||
inside: { | ||
// Status, e.g. 200 OK | ||
'property': { | ||
pattern: /(^HTTP\/1.[01] )\d.*/i, | ||
lookbehind: true | ||
// HTTP Version | ||
'http-version': { | ||
pattern: /^HTTP\/[0-9.]+/, | ||
alias: 'property' | ||
}, | ||
// Status Code | ||
'status-code': { | ||
pattern: /^(\s)\d+(?=\s)/, | ||
lookbehind: true, | ||
alias: 'number' | ||
}, | ||
// Reason Phrase | ||
'reason-phrase': { | ||
pattern: /^(\s).+/, | ||
lookbehind: true, | ||
alias: 'string' | ||
} | ||
} | ||
}, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,126 @@ | ||
POST http://example.com HTTP/1.0 | ||
GET http://localhost:9999/foo.html HTTP/1.1 | ||
PUT http://www.example.com HTTP/2.0 | ||
DELETE https://example.com HTTP/1.1 | ||
OPTIONS https://www.example.com HTTP/1.1 | ||
PATCH http://example.com HTTP/1.0 | ||
TRACE http://example.com HTTP/1.0 | ||
CONNECT http://example.com HTTP/1.0 | ||
GET /path/to/foo.html HTTP/1.1 | ||
GET / HTTP/1.0 | ||
GET / HTTP/1.1 | ||
GET /path/to/file HTTP/1.1 | ||
GET /path/to/file?a=1&b=2 HTTP/1.1 | ||
GET http://example.com HTTP/1.1 | ||
GET https://example.com HTTP/1.1 | ||
GET https://example.com/ HTTP/1.1 | ||
GET https://example.com/path/to/file?a=1&b=2 HTTP/1.1 | ||
GET https://example.com:443/path/to/file?a=1&b=2 HTTP/1.1 | ||
GET https://user:[email protected]:443/path/to/file?a=1&b=2 HTTP/1.1 | ||
HEAD / HTTP/1.1 | ||
POST / HTTP/1.1 | ||
PUT / HTTP/1.1 | ||
DELETE / HTTP/1.1 | ||
CONNECT / HTTP/1.1 | ||
OPTIONS / HTTP/1.1 | ||
TRACE / HTTP/1.1 | ||
PATCH / HTTP/1.1 | ||
PRI / HTTP/1.1 | ||
SEARCH / HTTP/1.1 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["request-line", [ | ||
["property", "POST"], | ||
" http://example.com HTTP/1.0" | ||
["method", "GET"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.0"] | ||
]], | ||
["request-line", [ | ||
["property", "GET"], | ||
" http://localhost", | ||
["attr-name", ":9999"], | ||
"/foo.html HTTP/1.1" | ||
["method", "GET"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "PUT"], | ||
" http://www.example.com HTTP/2.0" | ||
["method", "GET"], | ||
["request-target", "/path/to/file"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "DELETE"], | ||
" https://example.com HTTP/1.1" | ||
["method", "GET"], | ||
["request-target", "/path/to/file?a=1&b=2"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "OPTIONS"], | ||
" https://www.example.com HTTP/1.1" | ||
["method", "GET"], | ||
["request-target", "http://example.com"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "PATCH"], | ||
" http://example.com HTTP/1.0" | ||
["method", "GET"], | ||
["request-target", "https://example.com"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "TRACE"], | ||
" http://example.com HTTP/1.0" | ||
["method", "GET"], | ||
["request-target", "https://example.com/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "CONNECT"], | ||
" http://example.com HTTP/1.0" | ||
["method", "GET"], | ||
["request-target", "https://example.com/path/to/file?a=1&b=2"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "GET"], | ||
" /path/to/foo.html HTTP/1.1" | ||
["method", "GET"], | ||
["request-target", "https://example.com:443/path/to/file?a=1&b=2"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["property", "GET"], | ||
" / HTTP/1.1" | ||
["method", "GET"], | ||
["request-target", "https://user:[email protected]:443/path/to/file?a=1&b=2"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "HEAD"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "POST"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "PUT"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "DELETE"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "CONNECT"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "OPTIONS"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "TRACE"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "PATCH"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "PRI"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]], | ||
["request-line", [ | ||
["method", "SEARCH"], | ||
["request-target", "/"], | ||
["http-version", "HTTP/1.1"] | ||
]] | ||
] | ||
|
||
|
I'm not sure this is the place to ask this, but I want to know your opinion.
We are working on SIP, which has message syntax very similar to HTTP (see example message here).
For supporting it with PrismJS we could either add a new "language" for it, or make "http" also support it.
My question is: do you think this is important to really specify all the HTTP methods here or can we change it to something like
[A-Z]+
(and also change the http-version to be[A-Z]+\/[0-9.]
)?What do you say?