Package: rfc-http-validate
rfc-http-validateValidating HTTP Messages in MarkdownValidating HTTP Messages in RFC XMLConfiguring Structured Type Information for FieldsInstallationUse with I-D-TemplateThis is a simple script to validate HTTP messages (possibly containingStructured Fields) inxml2rfcv3documents andkramdown-rfcdocuments.It checks that the content of an HTTP message:Optionally, starts with a valid HTTP/1.1 request or status lineHas one or more HTTP/1.1 header field lines, possibly with line folding (so that long lines can be formatted within the constraints of the RFC format)Optionally, has a response body, separated from the header fields with a single empty lineThe start line will be checked that the method or status code is reasonable, and that the version identifierHTTP/1.1is correct. The URL in requests will not be validated, however.Header fields will be validated for general syntax. Additionally, header field names that are configured with structured type information (see below) will be validated according to that type.The body, if present, is currently ignored (i.e., theContent-Lengthis not checked).If anRFC8792\\wrapping header is present, lines will be unwrapped first (i.e., before unfolding, as per above). This is useful for long lines with binary content (which cannot contain whitespace); e.g.,<sourcecodetype="http-message">#NOTE:'\'linewrappingperRFC8792

Signature:sig1=:K2qGT5srn2OGbOIDzQ6kYT+ruaycnDAAUpKv+ePFfD0RAxn/1BUe\Zx/Kdrq32DrfakQ6bPsvB9aqZqognNT6be4olHROIkeV879RrsrObury8L9SCEibe\oHyqU/yCjphSmEdd7WD+zrchK57quskKwRefy2iEC5S2uAH0EPyOZKWlvbKmKu5q4\CaB8X/I5/+HLZLGvDiezqi6/7p2Gngf5hwZ0lSdy39vyNMaaAT0tKo6nuVw0S1MVg\1Q7MpWYZs0soHjttq0uLIA3DIbQfLiIvK6/l0BdWTU7+2uQj7lBkQAsFZHoA96ZZg\FquQrXRlmYOh+Hx5D9fJkXcXe5tmAg==:</sourcecode>Validating HTTP Messages in MarkdownIn Markdown, all you need to do is adorn your messages withhttp-messsage; for example:~~~ http-message
HTTP/1.1 200 OK
Foo: bar, baz
~~~Then, run:rfc-http-validate my-draft.mdValidating HTTP Messages in RFC XMLIn XML, this script examines allsourcecodeandartworkelements; when one has atypeofhttp-message.For example,<sourcecodetype="http-message">Foo:bar;baz
Foo:one,two</sourcecode>Then, run:rfc-http-validate my-draft.xmlNote that in your XML, theremust not be any whitespaceat the start of lines, unless they're continuation of previous lines (folding, as seen above).Configuring Structured Type Information for FieldsBy default, the types of existing Structured Fields (including those that are compatible with Structured Fields; seeRetrofit Structured Fields for HTTP) are known. Type information for other fields can be added on the command line or through a file.To pass a type on the command line, use the--list,--dictionaryor--itemarguments as appropriate, followed by the field name. For example:rfc-http-validate --list Foo --list Bar --item Baz my_draft.xmlHere,FooandBarwill be validated as Structured Lists, whileBazwill be validated as a Structured Item.Alternatively, you can collect this information in a JSON file, with the top-level object keys being field names, and their values beinglist,dictoritemas appropriate. Thus, the configuration in the example above could be expressed in a JSON filesf.jsonas:{"Foo":"list","Bar":"list","Baz":"item"}... and passed to the script like this:rfc-http-validate --map sf.json my_draft.xmlInstallationThe script requires Python 3, and can be installed with pip:pip3 install rfc-http-validateUse with I-D-TemplateTo automatically lint files with MT'sI-D-Template:Addrfc-http-validatetorequirements.txt(creating it if necessary)Add asf.jsonfile containing the field(s) your draft uses mapped to one ofitem,list, ordictAdd the following toMakefile:lint::http-lintrfc-http-validate?=rfc-http-validate.SECONDARY:$(drafts_xml).PHONY:http-linthttp-lint:$(addsuffix.http-lint.txt,$(addprefix.,$(drafts))).PHONY:.%.http-lint.txt.%.http-lint.txt:%.xml$(DEPS_FILES)$(trace)$<-shttp-lint$(rfc-http-validate)-q-msf.json$<@touch$@