From 8371b40077c0177d743bb3dfed7e2b56cba18328 Mon Sep 17 00:00:00 2001 From: Paolo Insogna Date: Tue, 27 Aug 2024 12:28:55 +0200 Subject: [PATCH] feat: Added support for RTSP and ICE response and the on_protocol_complete callback. (#477) * feat: Added support for RTSP and ICE response and the on_protocol_complete callback. * chore: Reduce instructions. * fix: Minor fixes. --- README.md | 2 + eslint.config.mjs | 2 +- src/llhttp/constants.ts | 1 + src/llhttp/http.ts | 53 ++++++++++++++++---- src/native/api.c | 14 ++++++ src/native/api.h | 2 + test/fixtures/extra.c | 22 +++++++++ test/md-test.ts | 13 +++-- test/request/connection.md | 46 ++++++++++++++++++ test/request/content-length.md | 36 ++++++++++++++ test/request/finish.md | 6 +++ test/request/invalid.md | 55 +++++++++++++++++++-- test/request/lenient-headers.md | 10 ++++ test/request/lenient-version.md | 2 + test/request/method.md | 32 ++++++++++++ test/request/pausing.md | 54 +++++++++++++++++++++ test/request/pipelining.md | 6 +++ test/request/sample.md | 34 +++++++++++++ test/request/transfer-encoding.md | 62 ++++++++++++++++++++++++ test/request/uri.md | 21 +++++++- test/response/connection.md | 50 +++++++++++++++++++ test/response/content-length.md | 8 +++ test/response/finish.md | 2 + test/response/invalid.md | 33 ++++++++++++- test/response/lenient-version.md | 2 + test/response/pausing.md | 22 +++++++++ test/response/pipelining.md | 6 +++ test/response/sample.md | 78 +++++++++++++++++++++++++++++- test/response/transfer-encoding.md | 20 ++++++++ 29 files changed, 671 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 28653aa0..a36874c9 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_ * `on_message_complete`: Invoked when a request/response has been completedly parsed. * `on_url_complete`: Invoked after the URL has been parsed. * `on_method_complete`: Invoked after the HTTP method has been parsed. +* `on_protocol_complete`: Invoked after the HTTP version has been parsed. * `on_version_complete`: Invoked after the HTTP version has been parsed. * `on_status_complete`: Invoked after the status code has been parsed. * `on_header_field_complete`: Invoked after a header name has been parsed. @@ -130,6 +131,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_ * `on_method`: Invoked when another character of the method is received. When parser is created with `HTTP_BOTH` and the input is a response, this also invoked for the sequence `HTTP/` of the first message. +* `on_protocol`: Invoked when another character of the protocol is received. * `on_version`: Invoked when another character of the version is received. * `on_header_field`: Invoked when another character of a header name is received. * `on_header_value`: Invoked when another character of a header value is received. diff --git a/eslint.config.mjs b/eslint.config.mjs index 8d64d690..cdef3a73 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,7 +4,7 @@ import tseslint from 'typescript-eslint'; import globals from 'globals'; export default tseslint.config( - { ignores: ["lib", "examples", "bench"] }, + { ignores: ["build", "lib", "examples", "bench"] }, eslint.configs.recommended, ...tseslint.configs.recommended, ...tseslint.configs.stylistic, diff --git a/src/llhttp/constants.ts b/src/llhttp/constants.ts index a0bcd66f..832f3750 100644 --- a/src/llhttp/constants.ts +++ b/src/llhttp/constants.ts @@ -45,6 +45,7 @@ export const ERROR: IntDict = { CB_CHUNK_EXTENSION_NAME_COMPLETE: 34, CB_CHUNK_EXTENSION_VALUE_COMPLETE: 35, CB_RESET: 31, + CB_PROTOCOL_COMPLETE: 38, }; export const TYPE: IntDict = { diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts index aa661bd6..20c50e80 100644 --- a/src/llhttp/http.ts +++ b/src/llhttp/http.ts @@ -25,6 +25,8 @@ const NODES: readonly string[] = [ 'req_or_res_method', + 'res_after_start', + 'res_after_protocol', 'res_http_major', 'res_http_dot', 'res_http_minor', @@ -41,6 +43,8 @@ const NODES: readonly string[] = [ 'req_first_space_before_url', 'req_spaces_before_url', 'req_http_start', + 'req_after_http_start', + 'req_after_protocol', 'req_http_version', 'req_http_major', 'req_http_dot', @@ -109,6 +113,7 @@ const NODES: readonly string[] = [ ]; interface ISpanMap { + readonly protocol: source.Span; readonly status: source.Span; readonly method: source.Span; readonly version: source.Span; @@ -121,6 +126,7 @@ interface ISpanMap { interface ICallbackMap { readonly onMessageBegin: source.code.Code; + readonly onProtocolComplete: source.code.Code; readonly onUrlComplete: source.code.Code; readonly onMethodComplete: source.code.Code; readonly onVersionComplete: source.code.Code; @@ -178,6 +184,7 @@ export class HTTP { chunkExtensionValue: p.span(p.code.span('llhttp__on_chunk_extension_value')), headerField: p.span(p.code.span('llhttp__on_header_field')), headerValue: p.span(p.code.span('llhttp__on_header_value')), + protocol: p.span(p.code.span('llhttp__on_protocol')), method: p.span(p.code.span('llhttp__on_method')), status: p.span(p.code.span('llhttp__on_status')), version: p.span(p.code.span('llhttp__on_version')), @@ -185,6 +192,7 @@ export class HTTP { this.callback = { // User callbacks + onProtocolComplete: p.code.match('llhttp__on_protocol_complete'), onUrlComplete: p.code.match('llhttp__on_url_complete'), onStatusComplete: p.code.match('llhttp__on_status_complete'), onMethodComplete: p.code.match('llhttp__on_method_complete'), @@ -206,7 +214,7 @@ export class HTTP { afterHeadersComplete: p.code.match('llhttp__after_headers_complete'), afterMessageComplete: p.code.match('llhttp__after_message_complete'), }; - + for (const name of NODES) { this.nodes.set(name, p.node(name) as Match); } @@ -313,9 +321,22 @@ export class HTTP { }; // Response + const endResponseProtocol = () => { + return this.span.protocol.end( + this.invokePausable('on_protocol_complete', ERROR.CB_PROTOCOL_COMPLETE, n('res_after_protocol'), + )); + } + n('start_res') - .match('HTTP/', span.version.start(n('res_http_major'))) - .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/')); + .otherwise(this.span.protocol.start(n('res_after_start'))); + + n('res_after_start') + .match([ 'HTTP', 'RTSP', 'ICE' ], endResponseProtocol()) + .otherwise(this.span.protocol.end(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/, RTSP/ or ICE/'))); + + n('res_after_protocol') + .match('/', span.version.start(n('res_http_major'))) + .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/, RTSP/ or ICE/')); n('res_http_major') .select(MAJOR, this.store('http_major', 'res_http_dot')) @@ -436,7 +457,7 @@ export class HTTP { ); const checkMethod = (methods: number[], error: string): Node => { - const success = n('req_http_version'); + const success = n('req_after_protocol'); const failure = p.error(ERROR.INVALID_CONSTANT, error); const map: Record = {}; @@ -444,18 +465,27 @@ export class HTTP { map[method] = success; } - return this.load('method', map, failure); + return this.span.protocol.end( + this.invokePausable('on_protocol_complete', ERROR.CB_PROTOCOL_COMPLETE, this.load('method', map, failure)), + ); }; n('req_http_start') - .match('HTTP/', checkMethod(METHODS_HTTP, + .match(' ', n('req_http_start')) + .otherwise(this.span.protocol.start(n('req_after_http_start'))); + + n('req_after_http_start') + .match('HTTP', checkMethod(METHODS_HTTP, 'Invalid method for HTTP/x.x request')) - .match('RTSP/', checkMethod(METHODS_RTSP, + .match('RTSP', checkMethod(METHODS_RTSP, 'Invalid method for RTSP/x.x request')) - .match('ICE/', checkMethod(METHODS_ICE, + .match('ICE', checkMethod(METHODS_ICE, 'Expected SOURCE method for ICE/x.x request')) - .match(' ', n('req_http_start')) - .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/')); + .otherwise(this.span.protocol.end(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/, RTSP/ or ICE/'))); + + n('req_after_protocol') + .match('/', n('req_http_version')) + .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/, RTSP/ or ICE/')); n('req_http_version').otherwise(span.version.start(n('req_http_major'))); @@ -1248,6 +1278,9 @@ export class HTTP { case 'on_message_begin': cb = this.callback.onMessageBegin; break; + case 'on_protocol_complete': + cb = this.callback.onProtocolComplete; + break; case 'on_url_complete': cb = this.callback.onUrlComplete; break; diff --git a/src/native/api.c b/src/native/api.c index 8c2ce3dc..785891c4 100644 --- a/src/native/api.c +++ b/src/native/api.c @@ -341,6 +341,20 @@ int llhttp__on_message_begin(llhttp_t* s, const char* p, const char* endp) { } +int llhttp__on_protocol(llhttp_t* s, const char* p, const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_protocol, p, endp - p); + return err; +} + + +int llhttp__on_protocol_complete(llhttp_t* s, const char* p, const char* endp) { + int err; + CALLBACK_MAYBE(s, on_protocol_complete); + return err; +} + + int llhttp__on_url(llhttp_t* s, const char* p, const char* endp) { int err; SPAN_CALLBACK_MAYBE(s, on_url, p, endp - p); diff --git a/src/native/api.h b/src/native/api.h index f1b8e506..5ee7967d 100644 --- a/src/native/api.h +++ b/src/native/api.h @@ -24,6 +24,7 @@ struct llhttp_settings_s { llhttp_cb on_message_begin; /* Possible return values 0, -1, HPE_USER */ + llhttp_data_cb on_protocol; llhttp_data_cb on_url; llhttp_data_cb on_status; llhttp_data_cb on_method; @@ -49,6 +50,7 @@ struct llhttp_settings_s { /* Possible return values 0, -1, `HPE_PAUSED` */ llhttp_cb on_message_complete; + llhttp_cb on_protocol_complete; llhttp_cb on_url_complete; llhttp_cb on_status_complete; llhttp_cb on_method_complete; diff --git a/test/fixtures/extra.c b/test/fixtures/extra.c index dadf8dca..4134946e 100644 --- a/test/fixtures/extra.c +++ b/test/fixtures/extra.c @@ -225,6 +225,28 @@ int llhttp__on_message_complete(llparse_t* s, const char* p, const char* endp) { } +int llhttp__on_protocol(llparse_t* s, const char* p, const char* endp) { + if (llparse__in_bench) + return 0; + + return llparse__print_span("protocol", p, endp); +} + + +int llhttp__on_protocol_complete(llparse_t* s, const char* p, const char* endp) { + if (llparse__in_bench) + return 0; + + llparse__print(p, endp, "protocol complete"); + + #ifdef LLHTTP__TEST_PAUSE_ON_PROTOCOL_COMPLETE + return LLPARSE__ERROR_PAUSE; + #else + return 0; + #endif +} + + int llhttp__on_status(llparse_t* s, const char* p, const char* endp) { if (llparse__in_bench) return 0; diff --git a/test/md-test.ts b/test/md-test.ts index b946a031..a96745cb 100644 --- a/test/md-test.ts +++ b/test/md-test.ts @@ -90,10 +90,11 @@ function run(name: string): void { const raw = fs.readFileSync(path.join(__dirname, name + '.md')).toString(); const groups = md.parse(raw); - function runSingleTest(ty: TestType, meta: Metadata, - input: string, - expected: readonly (string | RegExp)[]): void { - test(`should pass for type="${ty}"`, { timeout: 60000 }, async () => { + function runSingleTest( + location: string, ty: TestType, meta: Metadata, + input: string, expected: readonly (string | RegExp)[] + ): void { + test(`should pass for type="${ty}" (location=${location})`, { timeout: 60000 }, async () => { const binary = await buildMode(ty, meta); await binary.check(input, expected, { noScan: meta.noScan === true, @@ -103,6 +104,8 @@ function run(name: string): void { function runTest(test: Test) { describe(test.name + ` at ${name}.md:${test.line + 1}`, () => { + const location = `${name}.md:${test.line + 1}` + let types: TestType[] = []; const isURL = test.values.has('url'); @@ -202,7 +205,7 @@ function run(name: string): void { continue; } - runSingleTest(ty, meta, input, fullExpected); + runSingleTest(location, ty, meta, input, fullExpected); } }); } diff --git a/test/request/connection.md b/test/request/connection.md index 68ed3e07..d1e6b905 100644 --- a/test/request/connection.md +++ b/test/request/connection.md @@ -19,6 +19,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -48,6 +50,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -62,6 +66,8 @@ off=45 len=3 span[method]="PUT" off=48 method complete off=49 len=4 span[url]="/url" off=54 url complete +off=54 len=4 span[protocol]="HTTP" +off=58 protocol complete off=59 len=3 span[version]="1.1" off=62 version complete off=64 len=10 span[header_field]="Connection" @@ -89,6 +95,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.0" off=17 version complete off=21 headers complete method=4 v=1/0 flags=0 content_length=0 @@ -118,6 +126,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.0" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -132,6 +142,8 @@ off=40 len=3 span[method]="PUT" off=43 method complete off=44 len=4 span[url]="/url" off=49 url complete +off=49 len=4 span[protocol]="HTTP" +off=53 protocol complete off=54 len=3 span[version]="1.1" off=57 version complete off=59 len=17 span[header_field]="Transfer-Encoding" @@ -162,6 +174,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=4 span[header_field]="Host" @@ -185,6 +199,8 @@ off=118 len=3 span[method]="GET" off=121 method complete off=122 len=1 span[url]="/" off=124 url complete +off=124 len=4 span[protocol]="HTTP" +off=128 protocol complete off=129 len=3 span[version]="1.1" off=132 version complete ``` @@ -205,6 +221,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -231,6 +249,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -265,6 +285,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=4 span[header_field]="Host" @@ -313,6 +335,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=4 span[header_field]="Host" @@ -340,6 +364,8 @@ off=137 len=3 span[method]="GET" off=140 method complete off=141 len=1 span[url]="/" off=143 url complete +off=143 len=4 span[protocol]="HTTP" +off=147 protocol complete off=148 len=3 span[version]="1.1" off=151 version complete ``` @@ -362,6 +388,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -395,6 +423,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=20 len=4 span[header_field]="Host" @@ -448,6 +478,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=20 len=10 span[header_field]="Connection" @@ -480,6 +512,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=20 len=10 span[header_field]="Connection" @@ -514,6 +548,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -538,6 +574,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=11 span[header_field]="Connection " @@ -577,6 +615,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -610,6 +650,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -652,6 +694,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=20 len=4 span[header_field]="Host" @@ -707,6 +751,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=5 span[url]="/demo" off=11 url complete +off=11 len=4 span[protocol]="HTTP" +off=15 protocol complete off=16 len=3 span[version]="1.1" off=19 version complete off=21 len=4 span[header_field]="Host" diff --git a/test/request/content-length.md b/test/request/content-length.md index 524d1838..0485f127 100644 --- a/test/request/content-length.md +++ b/test/request/content-length.md @@ -17,6 +17,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -53,6 +55,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -83,6 +87,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -107,6 +113,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -135,6 +143,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -164,6 +174,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -192,6 +204,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=10 span[header_field]="Connection" @@ -229,6 +243,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -258,6 +274,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=36 span[url]="/get_funky_content_length_body_hello" off=41 url complete +off=41 len=4 span[protocol]="HTTP" +off=45 protocol complete off=46 len=3 span[version]="1.0" off=49 version complete off=51 len=14 span[header_field]="conTENT-Length" @@ -285,6 +303,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -310,6 +330,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -334,6 +356,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -358,6 +382,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -381,6 +407,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=26 error code=10 reason="Invalid header token" @@ -405,6 +433,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -420,6 +450,8 @@ off=42 len=4 span[method]="POST" off=46 method complete off=47 len=4 span[url]="/url" off=52 url complete +off=52 len=4 span[protocol]="HTTP" +off=56 protocol complete off=57 len=3 span[version]="1.1" off=60 version complete off=62 len=14 span[header_field]="Content-Length" @@ -446,6 +478,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" @@ -470,6 +504,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=14 span[header_field]="Content-Length" diff --git a/test/request/finish.md b/test/request/finish.md index 710daa54..156e38d6 100644 --- a/test/request/finish.md +++ b/test/request/finish.md @@ -18,6 +18,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=18 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -40,6 +42,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=14 span[header_field]="Content-Length" @@ -62,6 +66,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=12 span[header_field]="Content-Leng" diff --git a/test/request/invalid.md b/test/request/invalid.md index d3a38c95..1fbf5fa0 100644 --- a/test/request/invalid.md +++ b/test/request/invalid.md @@ -17,7 +17,9 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=18 span[url]="/music/sweet/music" off=23 url complete -off=27 error code=8 reason="Expected SOURCE method for ICE/x.x request" +off=23 len=3 span[protocol]="ICE" +off=26 protocol complete +off=26 error code=8 reason="Expected SOURCE method for ICE/x.x request" ``` ### ICE protocol, but not really @@ -36,7 +38,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=18 span[url]="/music/sweet/music" off=23 url complete -off=24 error code=8 reason="Expected HTTP/" +off=23 len=1 span[protocol]="I" +off=24 error code=8 reason="Expected HTTP/, RTSP/ or ICE/" ``` ### RTSP protocol and PUT method @@ -55,7 +58,9 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=18 span[url]="/music/sweet/music" off=23 url complete -off=28 error code=8 reason="Invalid method for RTSP/x.x request" +off=23 len=4 span[protocol]="RTSP" +off=27 protocol complete +off=27 error code=8 reason="Invalid method for RTSP/x.x request" ``` ### HTTP protocol and ANNOUNCE method @@ -74,7 +79,9 @@ off=0 len=8 span[method]="ANNOUNCE" off=8 method complete off=9 len=18 span[url]="/music/sweet/music" off=28 url complete -off=33 error code=8 reason="Invalid method for HTTP/x.x request" +off=28 len=4 span[protocol]="HTTP" +off=32 protocol complete +off=32 error code=8 reason="Invalid method for HTTP/x.x request" ``` ### Headers separated by CR @@ -93,6 +100,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=3 span[header_field]="Foo" @@ -121,6 +130,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=4 span[header_field]="Host" @@ -151,6 +162,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=10 span[header_field]="Connection" @@ -183,6 +196,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=10 span[header_field]="Connection" @@ -219,6 +234,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=10 span[header_field]="Connection" @@ -254,6 +271,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=4 span[header_field]="Host" @@ -281,6 +300,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=18 error code=10 reason="Invalid header token" @@ -302,6 +323,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=19 error code=10 reason="Invalid header token" @@ -323,6 +346,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 error code=10 reason="Invalid header token" @@ -361,6 +386,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=20 error code=10 reason="Invalid header token" @@ -384,6 +411,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -411,6 +440,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -442,6 +473,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -467,6 +500,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="5.6" off=14 error code=9 reason="Invalid HTTP version" ``` @@ -485,6 +520,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=17 error code=30 reason="Unexpected space after start line" @@ -521,6 +558,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=16 error code=9 reason="Expected CRLF after version" @@ -556,6 +595,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=16 len=17 span[header_field]="Transfer-Encoding" @@ -628,6 +669,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=6 span[url]="/hello" off=12 url complete +off=12 len=4 span[protocol]="HTTP" +off=16 protocol complete off=17 len=3 span[version]="1.1" off=20 version complete off=22 len=4 span[header_field]="Host" @@ -662,6 +705,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=6 span[url]="/hello" off=12 url complete +off=12 len=4 span[protocol]="HTTP" +off=16 protocol complete off=17 len=3 span[version]="1.1" off=20 version complete off=22 len=4 span[header_field]="Host" @@ -681,6 +726,8 @@ off=72 len=3 span[method]="GET" off=75 method complete off=76 len=4 span[url]="/bye" off=81 url complete +off=81 len=4 span[protocol]="HTTP" +off=85 protocol complete off=86 len=3 span[version]="1.1" off=89 version complete off=91 len=4 span[header_field]="Host" diff --git a/test/request/lenient-headers.md b/test/request/lenient-headers.md index 05e105f8..5435b3f9 100644 --- a/test/request/lenient-headers.md +++ b/test/request/lenient-headers.md @@ -19,6 +19,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=7 span[header_field]="Header1" @@ -49,6 +51,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=7 span[header_field]="Header1" @@ -63,6 +67,8 @@ off=38 len=3 span[method]="GET" off=41 method complete off=42 len=4 span[url]="/url" off=47 url complete +off=47 len=4 span[protocol]="HTTP" +off=51 protocol complete off=52 len=3 span[version]="1.1" off=55 version complete off=57 len=7 span[header_field]="Header1" @@ -90,6 +96,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=7 span[header_field]="Header1" @@ -119,6 +127,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=10 span[header_field]="Connection" diff --git a/test/request/lenient-version.md b/test/request/lenient-version.md index 41855569..a90ba06d 100644 --- a/test/request/lenient-version.md +++ b/test/request/lenient-version.md @@ -16,6 +16,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="5.6" off=14 version complete off=18 headers complete method=1 v=5/6 flags=0 content_length=0 diff --git a/test/request/method.md b/test/request/method.md index 47225018..cc6553f2 100644 --- a/test/request/method.md +++ b/test/request/method.md @@ -16,6 +16,8 @@ off=0 len=6 span[method]="REPORT" off=6 method complete off=7 len=5 span[url]="/test" off=13 url complete +off=13 len=4 span[protocol]="HTTP" +off=17 protocol complete off=18 len=3 span[version]="1.1" off=21 version complete off=25 headers complete method=20 v=1/1 flags=0 content_length=0 @@ -40,6 +42,8 @@ off=0 len=7 span[method]="CONNECT" off=7 method complete off=8 len=24 span[url]="0-home0.netscape.com:443" off=33 url complete +off=33 len=4 span[protocol]="HTTP" +off=37 protocol complete off=38 len=3 span[version]="1.0" off=41 version complete off=43 len=10 span[header_field]="User-agent" @@ -72,6 +76,8 @@ off=0 len=7 span[method]="CONNECT" off=7 method complete off=8 len=22 span[url]="HOME0.NETSCAPE.COM:443" off=31 url complete +off=31 len=4 span[protocol]="HTTP" +off=35 protocol complete off=36 len=3 span[version]="1.0" off=39 version complete off=41 len=10 span[header_field]="User-agent" @@ -105,6 +111,8 @@ off=0 len=7 span[method]="CONNECT" off=7 method complete off=8 len=15 span[url]="foo.bar.com:443" off=24 url complete +off=24 len=4 span[protocol]="HTTP" +off=28 protocol complete off=29 len=3 span[version]="1.0" off=32 version complete off=34 len=10 span[header_field]="User-agent" @@ -142,6 +150,8 @@ off=0 len=8 span[method]="M-SEARCH" off=8 method complete off=9 len=1 span[url]="*" off=11 url complete +off=11 len=4 span[protocol]="HTTP" +off=15 protocol complete off=16 len=3 span[version]="1.1" off=19 version complete off=21 len=4 span[header_field]="HOST" @@ -179,6 +189,8 @@ off=0 len=5 span[method]="PATCH" off=5 method complete off=6 len=9 span[url]="/file.txt" off=16 url complete +off=16 len=4 span[protocol]="HTTP" +off=20 protocol complete off=21 len=3 span[version]="1.1" off=24 version complete off=26 len=4 span[header_field]="Host" @@ -218,6 +230,8 @@ off=0 len=5 span[method]="PURGE" off=5 method complete off=6 len=9 span[url]="/file.txt" off=16 url complete +off=16 len=4 span[protocol]="HTTP" +off=20 protocol complete off=21 len=3 span[version]="1.1" off=24 version complete off=26 len=4 span[header_field]="Host" @@ -244,6 +258,8 @@ off=0 len=6 span[method]="SEARCH" off=6 method complete off=7 len=1 span[url]="/" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=4 span[header_field]="Host" @@ -272,6 +288,8 @@ off=0 len=4 span[method]="LINK" off=4 method complete off=5 len=18 span[url]="/images/my_dog.jpg" off=24 url complete +off=24 len=4 span[protocol]="HTTP" +off=28 protocol complete off=29 len=3 span[version]="1.1" off=32 version complete off=34 len=4 span[header_field]="Host" @@ -307,6 +325,8 @@ off=0 len=6 span[method]="UNLINK" off=6 method complete off=7 len=18 span[url]="/images/my_dog.jpg" off=26 url complete +off=26 len=4 span[protocol]="HTTP" +off=30 protocol complete off=31 len=3 span[version]="1.1" off=34 version complete off=36 len=4 span[header_field]="Host" @@ -337,6 +357,8 @@ off=0 len=6 span[method]="SOURCE" off=6 method complete off=7 len=18 span[url]="/music/sweet/music" off=26 url complete +off=26 len=4 span[protocol]="HTTP" +off=30 protocol complete off=31 len=3 span[version]="1.1" off=34 version complete off=36 len=4 span[header_field]="Host" @@ -363,6 +385,8 @@ off=0 len=6 span[method]="SOURCE" off=6 method complete off=7 len=18 span[url]="/music/sweet/music" off=26 url complete +off=26 len=3 span[protocol]="ICE" +off=29 protocol complete off=30 len=3 span[version]="1.0" off=33 version complete off=35 len=4 span[header_field]="Host" @@ -391,6 +415,8 @@ off=0 len=7 span[method]="OPTIONS" off=7 method complete off=8 len=18 span[url]="/music/sweet/music" off=27 url complete +off=27 len=4 span[protocol]="RTSP" +off=31 protocol complete off=32 len=3 span[version]="1.0" off=35 version complete off=37 len=4 span[header_field]="Host" @@ -417,6 +443,8 @@ off=0 len=8 span[method]="ANNOUNCE" off=8 method complete off=9 len=18 span[url]="/music/sweet/music" off=28 url complete +off=28 len=4 span[protocol]="RTSP" +off=32 protocol complete off=33 len=3 span[version]="1.0" off=36 version complete off=38 len=4 span[header_field]="Host" @@ -444,6 +472,8 @@ off=0 len=3 span[method]="PRI" off=3 method complete off=4 len=1 span[url]="*" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=24 error code=23 reason="Pause on PRI/Upgrade" @@ -468,6 +498,8 @@ off=0 len=5 span[method]="QUERY" off=5 method complete off=6 len=9 span[url]="/contacts" off=16 url complete +off=16 len=4 span[protocol]="HTTP" +off=20 protocol complete off=21 len=3 span[version]="1.1" off=24 version complete off=26 len=4 span[header_field]="Host" diff --git a/test/request/pausing.md b/test/request/pausing.md index 8e501e32..bcc3caa9 100644 --- a/test/request/pausing.md +++ b/test/request/pausing.md @@ -18,6 +18,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -45,6 +47,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -57,6 +61,36 @@ off=41 message complete off=41 pause ``` +### on_protocol_complete + + +```http +POST / HTTP/1.1 +Content-Length: 3 + +abc +``` + +```log +off=0 message begin +off=0 len=4 span[method]="POST" +off=4 method complete +off=5 len=1 span[url]="/" +off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete +off=11 pause +off=12 len=3 span[version]="1.1" +off=15 version complete +off=17 len=14 span[header_field]="Content-Length" +off=32 header_field complete +off=33 len=1 span[header_value]="3" +off=36 header_value complete +off=38 headers complete method=3 v=1/1 flags=20 content_length=3 +off=38 len=3 span[body]="abc" +off=41 message complete +``` + ### on_method_complete @@ -74,6 +108,8 @@ off=4 method complete off=4 pause off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -102,6 +138,8 @@ off=4 method complete off=5 len=1 span[url]="/" off=7 url complete off=7 pause +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -129,6 +167,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=15 pause @@ -157,6 +197,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -185,6 +227,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -213,6 +257,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=14 span[header_field]="Content-Length" @@ -245,6 +291,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=17 span[header_field]="Transfer-Encoding" @@ -282,6 +330,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=17 span[header_field]="Transfer-Encoding" @@ -322,6 +372,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=17 span[header_field]="Transfer-Encoding" @@ -363,6 +415,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=17 span[header_field]="Transfer-Encoding" diff --git a/test/request/pipelining.md b/test/request/pipelining.md index bdfe6ab1..43c3bff3 100644 --- a/test/request/pipelining.md +++ b/test/request/pipelining.md @@ -25,6 +25,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=4 span[url]="/aaa" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=20 len=14 span[header_field]="Content-Length" @@ -40,6 +42,8 @@ off=46 len=3 span[method]="PUT" off=49 method complete off=50 len=4 span[url]="/bbb" off=55 url complete +off=55 len=4 span[protocol]="HTTP" +off=59 protocol complete off=60 len=3 span[version]="1.1" off=63 version complete off=65 len=14 span[header_field]="Content-Length" @@ -55,6 +59,8 @@ off=92 len=5 span[method]="PATCH" off=97 method complete off=98 len=4 span[url]="/ccc" off=103 url complete +off=103 len=4 span[protocol]="HTTP" +off=107 protocol complete off=108 len=3 span[version]="1.1" off=111 version complete off=113 len=14 span[header_field]="Content-Length" diff --git a/test/request/sample.md b/test/request/sample.md index de2ceb96..a82d97e6 100644 --- a/test/request/sample.md +++ b/test/request/sample.md @@ -20,6 +20,8 @@ off=0 len=7 span[method]="OPTIONS" off=7 method complete off=8 len=4 span[url]="/url" off=13 url complete +off=13 len=4 span[protocol]="HTTP" +off=17 protocol complete off=18 len=3 span[version]="1.1" off=21 version complete off=23 len=7 span[header_field]="Header1" @@ -54,6 +56,8 @@ off=0 len=4 span[method]="HEAD" off=4 method complete off=5 len=4 span[url]="/url" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=22 headers complete method=2 v=1/1 flags=0 content_length=0 @@ -78,6 +82,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=5 span[url]="/test" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.1" off=18 version complete off=20 len=10 span[header_field]="User-Agent" @@ -119,6 +125,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=12 span[url]="/favicon.ico" off=17 url complete +off=17 len=4 span[protocol]="HTTP" +off=21 protocol complete off=22 len=3 span[version]="1.1" off=25 version complete off=27 len=4 span[header_field]="Host" @@ -173,6 +181,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=9 span[url]="/dumbpack" off=14 url complete +off=14 len=4 span[protocol]="HTTP" +off=18 protocol complete off=19 len=3 span[version]="1.1" off=22 version complete off=24 len=13 span[header_field]="aaaaaaaaaaaaa" @@ -198,6 +208,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=29 span[url]="/get_no_headers_no_body/world" off=34 url complete +off=34 len=4 span[protocol]="HTTP" +off=38 protocol complete off=39 len=3 span[version]="1.1" off=42 version complete off=46 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -220,6 +232,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=23 span[url]="/get_one_header_no_body" off=28 url complete +off=28 len=4 span[protocol]="HTTP" +off=32 protocol complete off=33 len=3 span[version]="1.1" off=36 version complete off=38 len=6 span[header_field]="Accept" @@ -251,6 +265,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=5 span[url]="/test" off=10 url complete +off=10 len=4 span[protocol]="HTTP" +off=14 protocol complete off=15 len=3 span[version]="1.0" off=18 version complete off=20 len=4 span[header_field]="Host" @@ -287,6 +303,8 @@ off=2 len=3 span[method]="GET" off=5 method complete off=6 len=5 span[url]="/test" off=12 url complete +off=12 len=4 span[protocol]="HTTP" +off=16 protocol complete off=17 len=3 span[version]="1.1" off=20 version complete off=24 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -340,6 +358,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=5 span[header_field]="Line1" @@ -399,6 +419,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=5 span[header_field]="Line1" @@ -422,6 +444,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=15 error code=2 reason="Expected CRLF after version" @@ -442,6 +466,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=15 len=4 span[header_field]="Line" @@ -465,6 +491,8 @@ off=2 len=3 span[method]="GET" off=5 method complete off=6 len=4 span[url]="/url" off=11 url complete +off=11 len=4 span[protocol]="HTTP" +off=15 protocol complete off=16 len=3 span[version]="1.1" off=19 version complete off=21 len=7 span[header_field]="Header1" @@ -493,6 +521,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Test" @@ -522,6 +552,8 @@ off=0 len=7 span[method]="OPTIONS" off=7 method complete off=8 len=4 span[url]="/url" off=13 url complete +off=13 len=4 span[protocol]="HTTP" +off=17 protocol complete off=18 len=3 span[version]="1.1" off=21 version complete off=23 len=7 span[header_field]="Header1" @@ -585,6 +617,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=14 span[header_field]="X-SSL-Nonsense" diff --git a/test/request/transfer-encoding.md b/test/request/transfer-encoding.md index b1b523dc..47b2e852 100644 --- a/test/request/transfer-encoding.md +++ b/test/request/transfer-encoding.md @@ -19,6 +19,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -48,6 +50,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -83,6 +87,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -118,6 +124,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=27 span[url]="/post_chunked_all_your_base" off=33 url complete +off=33 len=4 span[protocol]="HTTP" +off=37 protocol complete off=38 len=3 span[version]="1.1" off=41 version complete off=43 len=17 span[header_field]="Transfer-Encoding" @@ -155,6 +163,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=25 span[url]="/two_chunks_mult_zero_end" off=31 url complete +off=31 len=4 span[protocol]="HTTP" +off=35 protocol complete off=36 len=3 span[version]="1.1" off=39 version complete off=41 len=17 span[header_field]="Transfer-Encoding" @@ -197,6 +207,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=27 span[url]="/chunked_w_trailing_headers" off=33 url complete +off=33 len=4 span[protocol]="HTTP" +off=37 protocol complete off=38 len=3 span[version]="1.1" off=41 version complete off=43 len=17 span[header_field]="Transfer-Encoding" @@ -244,6 +256,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=32 span[url]="/chunked_w_unicorns_after_length" off=38 url complete +off=38 len=4 span[protocol]="HTTP" +off=42 protocol complete off=43 len=3 span[version]="1.1" off=46 version complete off=48 len=17 span[header_field]="Transfer-Encoding" @@ -295,6 +309,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=32 span[url]="/chunked_w_unicorns_after_length" off=38 url complete +off=38 len=4 span[protocol]="HTTP" +off=42 protocol complete off=43 len=3 span[version]="1.1" off=46 version complete off=48 len=4 span[header_field]="Host" @@ -330,6 +346,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=32 span[url]="/chunked_w_unicorns_after_length" off=38 url complete +off=38 len=4 span[protocol]="HTTP" +off=42 protocol complete off=43 len=3 span[version]="1.1" off=46 version complete off=48 len=4 span[header_field]="Host" @@ -366,6 +384,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=32 span[url]="/chunked_w_unicorns_after_length" off=38 url complete +off=38 len=4 span[protocol]="HTTP" +off=42 protocol complete off=43 len=3 span[version]="1.1" off=46 version complete off=48 len=17 span[header_field]="Transfer-Encoding" @@ -422,6 +442,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=32 span[url]="/chunked_w_unicorns_after_length" off=38 url complete +off=38 len=4 span[protocol]="HTTP" +off=42 protocol complete off=43 len=3 span[version]="1.1" off=46 version complete off=48 len=17 span[header_field]="Transfer-Encoding" @@ -458,6 +480,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -486,6 +510,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -525,6 +551,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -565,6 +593,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +off=7 len=4 span[protocol]="HTTP" +off=11 protocol complete off=12 len=3 span[version]="1.1" off=15 version complete off=17 len=4 span[header_field]="Host" @@ -597,6 +627,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -627,6 +659,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -660,6 +694,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -692,6 +728,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -731,6 +769,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -772,6 +812,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -816,6 +858,8 @@ off=0 len=4 span[method]="POST" off=4 method complete off=5 len=38 span[url]="/post_identity_body_world?q=search#hey" off=44 url complete +off=44 len=4 span[protocol]="HTTP" +off=48 protocol complete off=49 len=3 span[version]="1.1" off=52 version complete off=54 len=6 span[header_field]="Accept" @@ -849,6 +893,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -881,6 +927,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -912,6 +960,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -952,6 +1002,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -999,6 +1051,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -1061,6 +1115,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -1102,6 +1158,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=6 len=4 span[protocol]="HTTP" +off=10 protocol complete off=11 len=3 span[version]="1.1" off=14 version complete off=16 len=4 span[header_field]="Host" @@ -1142,6 +1200,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" @@ -1171,6 +1231,8 @@ off=0 len=3 span[method]="PUT" off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=9 len=4 span[protocol]="HTTP" +off=13 protocol complete off=14 len=3 span[version]="1.1" off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" diff --git a/test/request/uri.md b/test/request/uri.md index f7f12b04..1915f264 100644 --- a/test/request/uri.md +++ b/test/request/uri.md @@ -16,6 +16,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=33 span[url]="/with_"lovely"_quotes?foo=\"bar\"" off=38 url complete +off=38 len=4 span[protocol]="HTTP" +off=42 protocol complete off=43 len=3 span[version]="1.1" off=46 version complete off=50 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -39,6 +41,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=21 span[url]="/test.cgi?foo=bar?baz" off=26 url complete +off=26 len=4 span[protocol]="HTTP" +off=30 protocol complete off=31 len=3 span[version]="1.1" off=34 version complete off=38 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -60,6 +64,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=29 span[url]="http://hypnotoad.org?hail=all" off=34 url complete +off=34 len=4 span[protocol]="HTTP" +off=38 protocol complete off=39 len=3 span[version]="1.1" off=42 version complete off=46 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -81,6 +87,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=34 span[url]="http://hypnotoad.org:1234?hail=all" off=39 url complete +off=39 len=4 span[protocol]="HTTP" +off=43 protocol complete off=44 len=3 span[version]="1.1" off=47 version complete off=51 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -106,6 +114,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=17 span[url]="/test.cgi?query=|" off=22 url complete +off=22 len=4 span[protocol]="HTTP" +off=26 protocol complete off=27 len=3 span[version]="1.1" off=30 version complete off=34 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -127,6 +137,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=25 span[url]="http://hypnotoad.org:1234" off=30 url complete +off=30 len=4 span[protocol]="HTTP" +off=34 protocol complete off=35 len=3 span[version]="1.1" off=38 version complete off=42 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -165,6 +177,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=40 span[url]="/forums/1/topics/2375?page=1#posts-17408" off=45 url complete +off=45 len=4 span[protocol]="HTTP" +off=49 protocol complete off=50 len=3 span[version]="1.1" off=53 version complete off=57 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -188,6 +202,8 @@ off=0 len=7 span[method]="CONNECT" off=7 method complete off=8 len=23 span[url]="home_0.netscape.com:443" off=32 url complete +off=32 len=4 span[protocol]="HTTP" +off=36 protocol complete off=37 len=3 span[version]="1.0" off=40 version complete off=42 len=10 span[header_field]="User-agent" @@ -218,6 +234,8 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=41 span[url]="http://a%12:b!&*$@hypnotoad.org:1234/toto" off=46 url complete +off=46 len=4 span[protocol]="HTTP" +off=50 protocol complete off=51 len=3 span[version]="1.1" off=54 version complete off=58 headers complete method=1 v=1/1 flags=0 content_length=0 @@ -239,5 +257,6 @@ off=0 len=3 span[method]="GET" off=3 method complete off=4 len=4 span[url]="/foo" off=9 url complete -off=9 error code=8 reason="Expected HTTP/" +off=9 len=0 span[protocol]="" +off=9 error code=8 reason="Expected HTTP/, RTSP/ or ICE/" ``` diff --git a/test/response/connection.md b/test/response/connection.md index 11f9eb6e..47f4b853 100644 --- a/test/response/connection.md +++ b/test/response/connection.md @@ -16,6 +16,8 @@ hello world ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -56,6 +58,8 @@ HTTP/1.0 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.0" off=8 version complete off=13 len=2 span[status]="OK" @@ -82,6 +86,8 @@ HTTP/1.0 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.0" off=8 version complete off=13 len=10 span[status]="No content" @@ -94,6 +100,8 @@ off=51 headers complete status=204 v=1/0 flags=1 content_length=0 off=51 message complete off=51 reset off=51 message begin +off=51 len=4 span[protocol]="HTTP" +off=55 protocol complete off=56 len=3 span[version]="1.0" off=59 version complete off=64 len=2 span[status]="OK" @@ -113,6 +121,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -134,6 +144,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=10 span[status]="No content" @@ -142,6 +154,8 @@ off=27 headers complete status=204 v=1/1 flags=0 content_length=0 off=27 message complete off=27 reset off=27 message begin +off=27 len=4 span[protocol]="HTTP" +off=31 protocol complete off=32 len=3 span[version]="1.1" off=35 version complete off=40 len=2 span[status]="OK" @@ -159,6 +173,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=10 span[status]="No content" @@ -187,6 +203,8 @@ Connection: close ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=10 span[status]="No content" @@ -219,6 +237,8 @@ Connection: close ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=10 span[status]="No content" @@ -249,6 +269,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=10 span[status]="No content" @@ -261,6 +283,8 @@ off=46 headers complete status=204 v=1/1 flags=2 content_length=0 off=46 message complete off=46 reset off=46 message begin +off=46 len=4 span[protocol]="HTTP" +off=50 protocol complete off=51 len=3 span[version]="1.1" off=54 version complete off=59 len=2 span[status]="OK" @@ -281,6 +305,8 @@ proto ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=19 span[status]="Switching Protocols" @@ -322,6 +348,8 @@ proto ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=19 span[status]="Switching Protocols" @@ -356,6 +384,8 @@ body ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -386,6 +416,8 @@ body ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -427,6 +459,8 @@ dy ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -471,6 +505,8 @@ hello ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=12 span[status]="Not Modified" @@ -483,6 +519,8 @@ off=49 headers complete status=304 v=1/1 flags=20 content_length=10 off=49 message complete off=51 reset off=51 message begin +off=51 len=4 span[protocol]="HTTP" +off=55 protocol complete off=56 len=3 span[version]="1.1" off=59 version complete off=64 len=2 span[status]="OK" @@ -514,6 +552,8 @@ hello ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=12 span[status]="Not Modified" @@ -526,6 +566,8 @@ off=57 headers complete status=304 v=1/1 flags=208 content_length=0 off=57 message complete off=57 reset off=57 message begin +off=57 len=4 span[protocol]="HTTP" +off=61 protocol complete off=62 len=3 span[version]="1.1" off=65 version complete off=70 len=2 span[status]="OK" @@ -559,6 +601,8 @@ Server: Python/3.10 aiohttp/4.0.0a2.dev0 ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=8 span[status]="Continue" @@ -567,6 +611,8 @@ off=25 headers complete status=100 v=1/1 flags=0 content_length=0 off=25 message complete off=27 reset off=27 message begin +off=27 len=4 span[protocol]="HTTP" +off=31 protocol complete off=32 len=3 span[version]="1.1" off=35 version complete off=40 len=9 span[status]="Not Found" @@ -610,6 +656,8 @@ response content ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=11 span[status]="Early Hints" @@ -622,6 +670,8 @@ off=72 headers complete status=103 v=1/1 flags=0 content_length=0 off=72 message complete off=72 reset off=72 message begin +off=72 len=4 span[protocol]="HTTP" +off=76 protocol complete off=77 len=3 span[version]="1.1" off=80 version complete off=85 len=2 span[status]="OK" diff --git a/test/response/content-length.md b/test/response/content-length.md index 6c339244..def15061 100644 --- a/test/response/content-length.md +++ b/test/response/content-length.md @@ -31,6 +31,8 @@ Connection: close ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -95,6 +97,8 @@ OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -131,6 +135,8 @@ Content-Length: 456 ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -144,6 +150,8 @@ off=40 skip body off=40 message complete off=40 reset off=40 message begin +off=40 len=4 span[protocol]="HTTP" +off=44 protocol complete off=45 len=3 span[version]="1.1" off=48 version complete off=53 len=2 span[status]="OK" diff --git a/test/response/finish.md b/test/response/finish.md index 2938b83b..8f75517c 100644 --- a/test/response/finish.md +++ b/test/response/finish.md @@ -14,6 +14,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" diff --git a/test/response/invalid.md b/test/response/invalid.md index 034fc4d9..461e9779 100644 --- a/test/response/invalid.md +++ b/test/response/invalid.md @@ -12,7 +12,8 @@ HTP/1.1 200 OK ```log off=0 message begin -off=2 error code=8 reason="Expected HTTP/" +off=0 len=2 span[protocol]="HT" +off=2 error code=8 reason="Expected HTTP/, RTSP/ or ICE/" ``` ### Extra digit in HTTP major version @@ -26,6 +27,8 @@ HTTP/01.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=1 span[version]="0" off=6 error code=9 reason="Expected dot" ``` @@ -41,6 +44,8 @@ HTTP/11.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=1 span[version]="1" off=6 error code=9 reason="Expected dot" ``` @@ -56,6 +61,8 @@ HTTP/1.01 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.0" off=8 version complete off=8 error code=9 reason="Expected space after version" @@ -73,6 +80,8 @@ HTTP/1.1\t200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=8 error code=9 reason="Expected space after version" @@ -89,6 +98,8 @@ off=8 error code=9 reason="Expected space after version" ```log off=1 message begin +off=1 len=4 span[protocol]="HTTP" +off=5 protocol complete off=6 len=3 span[version]="1.1" off=9 version complete off=9 error code=9 reason="Expected space after version" @@ -106,6 +117,8 @@ Foo: 1\rBar: 2 ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -127,6 +140,8 @@ HTTP/5.6 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="5.6" off=8 error code=9 reason="Invalid HTTP version" ``` @@ -141,6 +156,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -159,6 +176,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=9 error code=13 reason="Invalid status code" @@ -175,6 +194,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=3 span[status]=" OK" @@ -193,6 +214,8 @@ HTTP/1.1 2 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=10 error code=13 reason="Invalid status code" @@ -207,6 +230,8 @@ HTTP/1.1 200 OK\nContent-Length: 0\n\n ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -222,6 +247,8 @@ HTTP/1.1 200 OK\nContent-Length: 0\n\n ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -247,6 +274,8 @@ BODY\n\ ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -266,6 +295,8 @@ BODY\n\ ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" diff --git a/test/response/lenient-version.md b/test/response/lenient-version.md index 86c6edef..9ddf5028 100644 --- a/test/response/lenient-version.md +++ b/test/response/lenient-version.md @@ -12,6 +12,8 @@ HTTP/5.6 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="5.6" off=8 version complete off=13 len=2 span[status]="OK" diff --git a/test/response/pausing.md b/test/response/pausing.md index d2e870b8..2ecc634b 100644 --- a/test/response/pausing.md +++ b/test/response/pausing.md @@ -14,6 +14,8 @@ abc ```log off=0 message begin off=0 pause +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -39,6 +41,8 @@ abc ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -65,6 +69,8 @@ abc ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=8 pause @@ -91,6 +97,8 @@ abc ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -117,6 +125,8 @@ abc ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -143,6 +153,8 @@ abc ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -169,6 +181,8 @@ abc ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -199,6 +213,8 @@ a ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -234,6 +250,8 @@ a;foo=bar ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -272,6 +290,8 @@ a;foo=bar ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -310,6 +330,8 @@ a ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" diff --git a/test/response/pipelining.md b/test/response/pipelining.md index 01e007a9..5be3d035 100644 --- a/test/response/pipelining.md +++ b/test/response/pipelining.md @@ -21,6 +21,8 @@ CCCC ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -34,6 +36,8 @@ off=38 len=3 span[body]="AAA" off=41 message complete off=43 reset off=43 message begin +off=43 len=4 span[protocol]="HTTP" +off=47 protocol complete off=48 len=3 span[version]="1.1" off=51 version complete off=56 len=7 span[status]="Created" @@ -47,6 +51,8 @@ off=86 len=4 span[body]="BBBB" off=90 message complete off=92 reset off=92 message begin +off=92 len=4 span[protocol]="HTTP" +off=96 protocol complete off=97 len=3 span[version]="1.1" off=100 version complete off=105 len=8 span[status]="Accepted" diff --git a/test/response/sample.md b/test/response/sample.md index be2e82dc..dbacb63d 100644 --- a/test/response/sample.md +++ b/test/response/sample.md @@ -15,6 +15,8 @@ Content-Length: 0 ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -35,6 +37,46 @@ off=73 headers complete status=200 v=1/1 flags=20 content_length=0 off=73 message complete ``` +## RTSP response + + +```http +RTSP/1.1 200 OK + + +``` + +```log +off=0 message begin +off=0 len=4 span[protocol]="RTSP" +off=4 protocol complete +off=5 len=3 span[version]="1.1" +off=8 version complete +off=13 len=2 span[status]="OK" +off=17 status complete +off=19 headers complete status=200 v=1/1 flags=0 content_length=0 +``` + +## ICE response + + +```http +ICE/1.1 200 OK + + +``` + +```log +off=0 message begin +off=0 len=3 span[protocol]="ICE" +off=3 protocol complete +off=4 len=3 span[version]="1.1" +off=7 version complete +off=12 len=2 span[status]="OK" +off=16 status complete +off=18 headers complete status=200 v=1/1 flags=0 content_length=0 +``` + ## Error on invalid response start Every response must start with `HTTP/`. @@ -48,7 +90,9 @@ HTTPER/1.1 200 OK ```log off=0 message begin -off=4 error code=8 reason="Expected HTTP/" +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete +off=4 error code=8 reason="Expected HTTP/, RTSP/ or ICE/" ``` ## Empty body should not trigger spurious span callbacks @@ -62,6 +106,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -94,6 +140,8 @@ _(Note the `$` char in header field)_ ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=17 span[status]="Moved Permanently" @@ -169,6 +217,8 @@ Transfer-Encoding: chunked ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=16 span[status]="MovedPermanently" @@ -229,6 +279,8 @@ HTTP/1.1 404 Not Found ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=9 span[status]="Not Found" @@ -247,6 +299,8 @@ HTTP/1.1 301 ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=14 status complete @@ -264,6 +318,8 @@ HTTP/1.1 200 \r\n\ ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=0 span[status]="" @@ -284,6 +340,8 @@ these headers are from http://news.ycombinator.com/ ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -303,6 +361,8 @@ these headers are from http://news.ycombinator.com/ ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -336,6 +396,8 @@ DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -383,6 +445,8 @@ Connection: keep-alive ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.0" off=8 version complete off=13 len=17 span[status]="Moved Permanently" @@ -451,6 +515,8 @@ Connection: close ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -523,6 +589,8 @@ Connection: keep-alive ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -552,6 +620,8 @@ Connection: close ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=19 span[status]="Oriƫntatieprobleem" @@ -583,6 +653,8 @@ HTTP/0.9 200 OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="0.9" off=8 version complete off=13 len=2 span[status]="OK" @@ -606,6 +678,8 @@ hello world ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -632,6 +706,8 @@ Content-Length: 0 ```log off=2 message begin +off=2 len=4 span[protocol]="HTTP" +off=6 protocol complete off=7 len=3 span[version]="1.1" off=10 version complete off=15 len=2 span[status]="OK" diff --git a/test/response/transfer-encoding.md b/test/response/transfer-encoding.md index 0f54c720..1d83c273 100644 --- a/test/response/transfer-encoding.md +++ b/test/response/transfer-encoding.md @@ -22,6 +22,8 @@ and this is the second one ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -51,6 +53,8 @@ World ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -81,6 +85,8 @@ World ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -120,6 +126,8 @@ OK ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -165,6 +173,8 @@ hello ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -216,6 +226,8 @@ aa ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -250,6 +262,8 @@ aa ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -285,6 +299,8 @@ hello ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -344,6 +360,8 @@ hello ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK" @@ -385,6 +403,8 @@ World ```log off=0 message begin +off=0 len=4 span[protocol]="HTTP" +off=4 protocol complete off=5 len=3 span[version]="1.1" off=8 version complete off=13 len=2 span[status]="OK"