netkit/http/spec

    Dark Mode
Search:
Group by:

这个模块包含 HTTP 规范相关的一些信息。

Consts

COLON = ':'
  Source Edit
COMMA = ','
  Source Edit
SEMICOLON = ';'
  Source Edit
CR = '\c'
  Source Edit
LF = '\n'
  Source Edit
CRLF = "\c\n"
  Source Edit
SP = ' '
  Source Edit
HTAB = '\t'
  Source Edit
WSP = {' ', '\t'}
  Source Edit

Procs

proc checkFieldName(s: string) {...}{.raises: [ValueError], tags: [].}

检查 s 是否为有效的 HTTP 头字段名称。

HTTP RFC 5234

DIGIT          =  %x30-39            ; 0-9
ALPHA          =  %x41-5A / %x61-7A  ; A-Z / a-z

HTTP RFC 7230

field-name     =  token
token          =  1*tchar
tchar          =  "!" / "#" / "$" / "%" / "&" / "'" / "*"
               /  "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
               /  DIGIT
               /  ALPHA
               ;  any VCHAR, except delimiters
  Source Edit
proc checkFieldValue(s: string) {...}{.raises: [ValueError], tags: [].}

检查 s 是否为有效的 HTTP 头字段值。

HTTP RFC 5234

HTAB           =  %x09       ; horizontal tab
SP             =  %x20       ; ' '
VCHAR          =  %x21-7E    ; visible (printing) characters

HTTP RFC 7230

field-value    =  \*( field-content / obs-fold )
field-content  =  field-vchar [ 1\*( SP / HTAB ) field-vchar ]
field-vchar    =  VCHAR / obs-text
obs-text       =  %x80-FF
obs-fold       =  CRLF 1\*( SP / HTAB )  ; obsolete line folding
  Source Edit