diff --git a/README.md b/README.md index 709cfeca..654bcf79 100644 --- a/README.md +++ b/README.md @@ -103,20 +103,26 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_ * `on_message_begin`: Invoked when a new request/response starts. * `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_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. * `on_header_value_complete`: Invoked after a header value has been parsed. -* `on_chunk_header`: Invoked after a new chunk is started. The current chunk length is stored - `parser->content_length`. +* `on_chunk_header`: Invoked after a new chunk is started. The current chunk length is stored in `parser->content_length`. * `on_chunk_complete`: Invoked after a new chunk is received. -* `on_reset`: Invoked after `on_message_complete` and before `on_message_begin` when a new message is received on the same parser. This is not invoked for the first message of the parser. +* `on_reset`: Invoked after `on_message_complete` and before `on_message_begin` when a new message + is received on the same parser. This is not invoked for the first message of the parser. The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_USER` (error from the callback): -* `on_url`: Invoked when the URL starts. -* `on_status`: Invoked when the status starts. -* `on_header_field`: Invoked when a new header name starts. -* `on_header_value`: Invoked when a new header value starts. +* `on_url`: Invoked when another character of the URL is received. +* `on_status`: Invoked when another character of the status is received. +* `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_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. The callback `on_headers_complete`, invoked when headers are completed, can return: diff --git a/src/llhttp/constants.ts b/src/llhttp/constants.ts index d0252a57..de02d4f7 100644 --- a/src/llhttp/constants.ts +++ b/src/llhttp/constants.ts @@ -38,6 +38,8 @@ export enum ERROR { CB_URL_COMPLETE = 26, CB_STATUS_COMPLETE = 27, + CB_METHOD_COMPLETE = 32, + CB_VERSION_COMPLETE = 33, CB_HEADER_FIELD_COMPLETE = 28, CB_HEADER_VALUE_COMPLETE = 29, CB_RESET = 31, diff --git a/src/llhttp/http.ts b/src/llhttp/http.ts index 5ca36811..e8749677 100644 --- a/src/llhttp/http.ts +++ b/src/llhttp/http.ts @@ -22,6 +22,7 @@ const NODES: ReadonlyArray = [ 'start', 'after_start', 'start_req', + 'after_start_req', 'start_res', 'start_req_or_res', @@ -31,6 +32,7 @@ const NODES: ReadonlyArray = [ 'res_http_dot', 'res_http_minor', 'res_http_end', + 'res_after_version', 'res_status_code', 'res_status_code_otherwise', 'res_status_start', @@ -40,6 +42,7 @@ const NODES: ReadonlyArray = [ 'req_first_space_before_url', 'req_spaces_before_url', 'req_http_start', + 'req_http_version', 'req_http_major', 'req_http_dot', 'req_http_minor', @@ -106,6 +109,8 @@ interface ISpanMap { readonly headerField: source.Span; readonly headerValue: source.Span; readonly status: source.Span; + readonly method: source.Span; + readonly version: source.Span; } interface ICallbackMap { @@ -118,6 +123,8 @@ interface ICallbackMap { readonly onMessageBegin: source.code.Code; readonly onMessageComplete: source.code.Code; readonly onUrlComplete: source.code.Code; + readonly onMethodComplete: source.code.Code; + readonly onVersionComplete: source.code.Code; readonly onStatusComplete: source.code.Code; readonly onHeaderFieldComplete: source.code.Code; readonly onHeaderValueComplete: source.code.Code; @@ -162,7 +169,9 @@ export class HTTP { body: p.span(p.code.span('llhttp__on_body')), headerField: p.span(p.code.span('llhttp__on_header_field')), headerValue: p.span(p.code.span('llhttp__on_header_value')), + 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')), }; /* tslint:disable:object-literal-sort-keys */ @@ -170,6 +179,8 @@ export class HTTP { // User callbacks onUrlComplete: p.code.match('llhttp__on_url_complete'), onStatusComplete: p.code.match('llhttp__on_status_complete'), + onMethodComplete: p.code.match('llhttp__on_method_complete'), + onVersionComplete: p.code.match('llhttp__on_version_complete'), onHeaderFieldComplete: p.code.match('llhttp__on_header_field_complete'), onHeaderValueComplete: p.code.match('llhttp__on_header_value_complete'), onHeadersComplete: p.code.match('llhttp__on_headers_complete'), @@ -252,53 +263,65 @@ export class HTTP { ); n('start_req_or_res') - .peek('H', n('req_or_res_method')) + .peek('H', this.span.method.start(n('req_or_res_method'))) .otherwise(this.update('type', TYPE.REQUEST, 'start_req')); n('req_or_res_method') .select(H_METHOD_MAP, this.store('method', - this.update('type', TYPE.REQUEST, 'req_first_space_before_url'))) - .match('HTTP/', this.update('type', TYPE.RESPONSE, 'res_http_major')) + this.update('type', TYPE.REQUEST, this.span.method.end( + this.invokePausable('on_method_complete', ERROR.CB_METHOD_COMPLETE, n('req_first_space_before_url')), + )), + )) + .match('HTTP/', this.span.method.end(this.update('type', TYPE.RESPONSE, + this.span.version.start(n('res_http_major'))))) .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Invalid word encountered')); const checkVersion = (destination: string): Node => { + const node = n(destination); + const errorNode = this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Invalid HTTP version')); + return this.testLenientFlags(LENIENT_FLAGS.VERSION, { - 1: n(destination), + 1: node, }, this.load('http_major', { 0: this.load('http_minor', { - 9: n(destination), - }, p.error(ERROR.INVALID_VERSION, 'Invalid HTTP version')), + 9: node, + }, errorNode), 1: this.load('http_minor', { - 0: n(destination), - 1: n(destination), - }, p.error(ERROR.INVALID_VERSION, 'Invalid HTTP version')), + 0: node, + 1: node, + }, errorNode), 2: this.load('http_minor', { - 0: n(destination), - }, p.error(ERROR.INVALID_VERSION, 'Invalid HTTP version')), - }, p.error(ERROR.INVALID_VERSION, 'Invalid HTTP version')), + 0: node, + }, errorNode), + }, errorNode), ); }; // Response n('start_res') - .match('HTTP/', n('res_http_major')) + .match('HTTP/', span.version.start(n('res_http_major'))) .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/')); n('res_http_major') .select(MAJOR, this.store('http_major', 'res_http_dot')) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Invalid major version')); + .otherwise(this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Invalid major version'))); n('res_http_dot') .match('.', n('res_http_minor')) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Expected dot')); + .otherwise(this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Expected dot'))); n('res_http_minor') .select(MINOR, this.store('http_minor', checkVersion('res_http_end'))) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Invalid minor version')); + .otherwise(this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Invalid minor version'))); n('res_http_end') + .otherwise(this.span.version.end().otherwise( + this.invokePausable('on_version_complete', ERROR.CB_VERSION_COMPLETE, 'res_after_version'), + )); + + n('res_after_version') .match(' ', this.update('status_code', 0, 'res_status_code')) .otherwise(p.error(ERROR.INVALID_VERSION, 'Expected space after version')); @@ -339,10 +362,12 @@ export class HTTP { } // Request + n('start_req').otherwise(this.span.method.start(n('after_start_req'))); - n('start_req') - .select(METHOD_MAP, - this.store('method', 'req_first_space_before_url')) + n('after_start_req') + .select(METHOD_MAP, this.store('method', this.span.method.end( + this.invokePausable('on_method_complete', ERROR.CB_METHOD_COMPLETE, n('req_first_space_before_url'), + )))) .otherwise(p.error(ERROR.INVALID_METHOD, 'Invalid method encountered')); n('req_first_space_before_url') @@ -374,7 +399,7 @@ export class HTTP { ); const checkMethod = (methods: METHODS[], error: string): Node => { - const success = n('req_http_major'); + const success = n('req_http_version'); const failure = p.error(ERROR.INVALID_CONSTANT, error); const map: { [key: number]: Node } = {}; @@ -395,21 +420,30 @@ export class HTTP { .match(' ', n('req_http_start')) .otherwise(p.error(ERROR.INVALID_CONSTANT, 'Expected HTTP/')); + n('req_http_version').otherwise(span.version.start(n('req_http_major'))); + n('req_http_major') .select(MAJOR, this.store('http_major', 'req_http_dot')) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Invalid major version')); + .otherwise(this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Invalid major version'))); n('req_http_dot') .match('.', n('req_http_minor')) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Expected dot')); + .otherwise(this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Expected dot'))); n('req_http_minor') .select(MINOR, this.store('http_minor', checkVersion('req_http_end'))) - .otherwise(p.error(ERROR.INVALID_VERSION, 'Invalid minor version')); - - n('req_http_end').otherwise(this.load('method', { - [METHODS.PRI]: n('req_pri_upgrade'), - }, n('req_http_complete'))); + .otherwise(this.span.version.end(p.error(ERROR.INVALID_VERSION, 'Invalid minor version'))); + + n('req_http_end').otherwise( + span.version.end().otherwise( + this.invokePausable( + 'on_version_complete', + ERROR.CB_VERSION_COMPLETE, + this.load('method', { + [METHODS.PRI]: n('req_pri_upgrade'), + }, n('req_http_complete')), + )), + ); n('req_http_complete') .match([ '\r\n', '\n' ], n('headers_start')) @@ -1028,7 +1062,6 @@ export class HTTP { return res; } - // TODO(indutny): use type for `name` private invokePausable(name: string, errorCode: ERROR, next: string | Node) : Node { let cb; @@ -1043,6 +1076,12 @@ export class HTTP { case 'on_status_complete': cb = this.callback.onStatusComplete; break; + case 'on_method_complete': + cb = this.callback.onMethodComplete; + break; + case 'on_version_complete': + cb = this.callback.onVersionComplete; + break; case 'on_header_field_complete': cb = this.callback.onHeaderFieldComplete; break; diff --git a/src/native/api.c b/src/native/api.c index 34789aba..84834402 100644 --- a/src/native/api.c +++ b/src/native/api.c @@ -60,6 +60,8 @@ const llhttp_settings_t wasm_settings = { wasm_on_message_begin, wasm_on_url, wasm_on_status, + NULL, + NULL, wasm_on_header_field, wasm_on_header_value, wasm_on_headers_complete_wrap, @@ -68,6 +70,12 @@ const llhttp_settings_t wasm_settings = { NULL, NULL, NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, }; @@ -309,6 +317,34 @@ int llhttp__on_status_complete(llhttp_t* s, const char* p, const char* endp) { } +int llhttp__on_method(llhttp_t* s, const char* p, const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_method, p, endp - p); + return err; +} + + +int llhttp__on_method_complete(llhttp_t* s, const char* p, const char* endp) { + int err; + CALLBACK_MAYBE(s, on_method_complete); + return err; +} + + +int llhttp__on_version(llhttp_t* s, const char* p, const char* endp) { + int err; + SPAN_CALLBACK_MAYBE(s, on_version, p, endp - p); + return err; +} + + +int llhttp__on_version_complete(llhttp_t* s, const char* p, const char* endp) { + int err; + CALLBACK_MAYBE(s, on_version_complete); + return err; +} + + int llhttp__on_header_field(llhttp_t* s, const char* p, const char* endp) { int err; SPAN_CALLBACK_MAYBE(s, on_header_field, p, endp - p); diff --git a/src/native/api.h b/src/native/api.h index 13cee13d..243b3b05 100644 --- a/src/native/api.h +++ b/src/native/api.h @@ -24,6 +24,8 @@ struct llhttp_settings_s { /* Possible return values 0, -1, HPE_USER */ llhttp_data_cb on_url; llhttp_data_cb on_status; + llhttp_data_cb on_method; + llhttp_data_cb on_version; llhttp_data_cb on_header_field; llhttp_data_cb on_header_value; @@ -45,6 +47,8 @@ struct llhttp_settings_s { llhttp_cb on_message_complete; llhttp_cb on_url_complete; llhttp_cb on_status_complete; + llhttp_cb on_method_complete; + llhttp_cb on_version_complete; llhttp_cb on_header_field_complete; llhttp_cb on_header_value_complete; diff --git a/test/fixtures/extra.c b/test/fixtures/extra.c index 6d988450..50d56daf 100644 --- a/test/fixtures/extra.c +++ b/test/fixtures/extra.c @@ -171,6 +171,49 @@ int llhttp__on_status_complete(llparse_t* s, const char* p, const char* endp) { } +int llhttp__on_method(llparse_t* s, const char* p, const char* endp) { + if (llparse__in_bench || s->type != HTTP_REQUEST) + return 0; + + return llparse__print_span("method", p, endp); +} + + +int llhttp__on_method_complete(llparse_t* s, const char* p, const char* endp) { + if (llparse__in_bench) + return 0; + + llparse__print(p, endp, "method complete"); + + #ifdef LLHTTP__TEST_PAUSE_ON_METHOD_COMPLETE + return LLPARSE__ERROR_PAUSE; + #else + return 0; + #endif +} + + +int llhttp__on_version(llparse_t* s, const char* p, const char* endp) { + if (llparse__in_bench) + return 0; + + return llparse__print_span("version", p, endp); +} + + +int llhttp__on_version_complete(llparse_t* s, const char* p, const char* endp) { + if (llparse__in_bench) + return 0; + + llparse__print(p, endp, "version complete"); + + #ifdef LLHTTP__TEST_PAUSE_ON_VERSION_COMPLETE + return LLPARSE__ERROR_PAUSE; + #else + return 0; + #endif +} + int llhttp__on_header_field(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 c8c556f6..a9495e35 100644 --- a/test/md-test.ts +++ b/test/md-test.ts @@ -305,7 +305,7 @@ run('response/content-length'); run('response/transfer-encoding'); run('response/invalid'); run('response/finish'); -run('request/lenient-version'); +run('response/lenient-version'); run('response/pausing'); run('response/pipelining'); diff --git a/test/request/connection.md b/test/request/connection.md index 49a185ac..3c2551e4 100644 --- a/test/request/connection.md +++ b/test/request/connection.md @@ -15,8 +15,12 @@ Connection: keep-alive ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=10 span[header_value]="keep-alive" @@ -40,8 +44,12 @@ Connection: keep-alive ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=10 span[header_value]="keep-alive" @@ -50,8 +58,12 @@ off=45 headers complete method=4 v=1/1 flags=1 content_length=0 off=45 message complete off=45 reset off=45 message begin +off=45 len=3 span[method]="PUT" +off=48 method complete off=49 len=4 span[url]="/url" off=54 url complete +off=59 len=3 span[version]="1.1" +off=62 version complete off=64 len=10 span[header_field]="Connection" off=75 header_field complete off=76 len=10 span[header_value]="keep-alive" @@ -73,8 +85,12 @@ PUT /url HTTP/1.1 ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url 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 off=21 message complete off=22 error code=5 reason="Data after `Connection: close`" @@ -98,8 +114,12 @@ Transfer-Encoding: chunked ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.0" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=1 span[header_value]="0" @@ -108,8 +128,12 @@ off=40 headers complete method=4 v=1/0 flags=20 content_length=0 off=40 message complete off=40 reset off=40 message begin +off=40 len=3 span[method]="PUT" +off=43 method complete off=44 len=4 span[url]="/url" off=49 url complete +off=54 len=3 span[version]="1.1" +off=57 version complete off=59 len=17 span[header_field]="Transfer-Encoding" off=77 header_field complete off=78 len=7 span[header_value]="chunked" @@ -134,8 +158,12 @@ _Note the trailing CRLF above_ ```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=12 len=3 span[version]="1.1" +off=15 version complete off=17 len=4 span[header_field]="Host" off=22 header_field complete off=23 len=15 span[header_value]="www.example.com" @@ -153,8 +181,12 @@ off=110 len=4 span[body]="q=42" off=114 message complete off=118 reset off=118 message begin +off=118 len=3 span[method]="GET" +off=121 method complete off=122 len=1 span[url]="/" off=124 url complete +off=129 len=3 span[version]="1.1" +off=132 version complete ``` ### Not treating `\r` as `-` @@ -169,8 +201,12 @@ Connection: keep\ralive ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=4 span[header_value]="keep" @@ -191,8 +227,12 @@ Connection: close ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=5 span[header_value]="close" @@ -221,8 +261,12 @@ _Note the trailing CRLF above_ ```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=12 len=3 span[version]="1.1" +off=15 version complete off=17 len=4 span[header_field]="Host" off=22 header_field complete off=23 len=15 span[header_value]="www.example.com" @@ -265,8 +309,12 @@ _Note the trailing CRLF above_ ```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=12 len=3 span[version]="1.1" +off=15 version complete off=17 len=4 span[header_field]="Host" off=22 header_field complete off=23 len=15 span[header_value]="www.example.com" @@ -288,8 +336,12 @@ off=129 len=4 span[body]="q=42" off=133 message complete off=137 reset off=137 message begin +off=137 len=3 span[method]="GET" +off=140 method complete off=141 len=1 span[url]="/" off=143 url complete +off=148 len=3 span[version]="1.1" +off=151 version complete ``` ## Parsing multiple tokens @@ -306,8 +358,12 @@ Connection: close, token, upgrade, token, keep-alive ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=40 span[header_value]="close, token, upgrade, token, keep-alive" @@ -335,8 +391,12 @@ Hot diggity dogg ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=15 len=3 span[version]="1.1" +off=18 version complete off=20 len=4 span[header_field]="Host" off=25 header_field complete off=26 len=11 span[header_value]="example.com" @@ -384,8 +444,12 @@ Hot diggity dogg ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=15 len=3 span[version]="1.1" +off=18 version complete off=20 len=10 span[header_field]="Connection" off=31 header_field complete off=32 len=19 span[header_value]="keep-alive, upgrade" @@ -412,8 +476,12 @@ Hot diggity dogg ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=15 len=3 span[version]="1.1" +off=18 version complete off=20 len=10 span[header_field]="Connection" off=31 header_field complete off=32 len=12 span[header_value]="keep-alive, " @@ -442,8 +510,12 @@ abcdefgh ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 error code=10 reason="Invalid header field char" ``` @@ -462,8 +534,12 @@ abcdefgh ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=11 span[header_field]="Connection " off=31 header_field complete off=32 len=7 span[header_value]="upgrade" @@ -497,8 +573,12 @@ Upgrade: ws ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=7 span[header_value]="upgrade" @@ -526,8 +606,12 @@ abcdefgh ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=7 span[header_value]="upgrade" @@ -564,8 +648,12 @@ Hot diggity dogg ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=5 span[url]="/demo" off=10 url complete +off=15 len=3 span[version]="1.1" +off=18 version complete off=20 len=4 span[header_field]="Host" off=25 header_field complete off=26 len=11 span[header_value]="example.com" @@ -615,8 +703,12 @@ Hot diggity dogg ```log off=0 message begin +off=0 len=4 span[method]="POST" +off=4 method complete off=5 len=5 span[url]="/demo" off=11 url complete +off=16 len=3 span[version]="1.1" +off=19 version complete off=21 len=4 span[header_field]="Host" off=26 header_field complete off=27 len=11 span[header_value]="example.com" diff --git a/test/request/content-length.md b/test/request/content-length.md index b6453bac..0101f615 100644 --- a/test/request/content-length.md +++ b/test/request/content-length.md @@ -13,8 +13,12 @@ abc ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=3 span[header_value]="003" @@ -45,8 +49,12 @@ abc ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=3 span[header_value]="003" @@ -71,8 +79,12 @@ Content-Length: 1000000000000000000000 ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=21 span[header_value]="100000000000000000000" @@ -91,8 +103,12 @@ Content-Length: 2 ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=1 span[header_value]="1" @@ -115,8 +131,12 @@ Transfer-Encoding: identity ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=1 span[header_value]="1" @@ -142,8 +162,12 @@ abcdefgh ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=7 span[header_value]="upgrade" @@ -166,8 +190,12 @@ abcdefgh ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=10 span[header_field]="Connection" off=30 header_field complete off=31 len=7 span[header_value]="upgrade" @@ -199,8 +227,12 @@ Transfer-Encoding: chunked ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=14 span[header_field]="Content-Length" off=34 header_field complete off=35 len=1 span[header_value]="1" @@ -224,8 +256,12 @@ HELLO ```log off=0 message begin +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=46 len=3 span[version]="1.0" +off=49 version complete off=51 len=14 span[header_field]="conTENT-Length" off=66 header_field complete off=67 len=1 span[header_value]="5" @@ -247,8 +283,12 @@ Content-Length: 42 ```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=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=34 len=3 span[header_value]="42 " @@ -268,8 +308,12 @@ Content-Length: 4 2 ```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=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=2 span[header_value]="4 " @@ -288,8 +332,12 @@ Content-Length: 13 37 ```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=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=3 span[header_value]="13 " @@ -308,8 +356,12 @@ Content-Length: ```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=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=34 error code=11 reason="Empty Content-Length" @@ -327,7 +379,11 @@ abc ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=26 error code=10 reason="Invalid header token" ``` diff --git a/test/request/finish.md b/test/request/finish.md index 2dd74a9c..710daa54 100644 --- a/test/request/finish.md +++ b/test/request/finish.md @@ -14,8 +14,12 @@ GET / HTTP/1.1 ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url 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 off=18 message complete off=NULL finish=0 @@ -32,8 +36,12 @@ Content-Length: 100 ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=14 span[header_field]="Content-Length" off=31 header_field complete off=32 len=3 span[header_value]="100" @@ -50,8 +58,12 @@ Content-Leng ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=12 span[header_field]="Content-Leng" off=NULL finish=2 ``` diff --git a/test/request/invalid.md b/test/request/invalid.md index 8b7a31c7..70e473f9 100644 --- a/test/request/invalid.md +++ b/test/request/invalid.md @@ -13,6 +13,8 @@ Host: example.com ```log off=0 message begin +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" @@ -30,6 +32,8 @@ Host: example.com ```log off=0 message begin +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/" @@ -47,6 +51,8 @@ Host: example.com ```log off=0 message begin +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" @@ -64,6 +70,8 @@ Host: example.com ```log off=0 message begin +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" @@ -81,8 +89,12 @@ Foo: 1\rBar: 2 ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=3 span[header_field]="Foo" off=20 header_field complete off=21 len=1 span[header_value]="1" @@ -101,8 +113,12 @@ Fo@: Failure ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=18 error code=10 reason="Invalid header token" ``` @@ -118,8 +134,12 @@ Foo\01\test: Bar ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=19 error code=10 reason="Invalid header token" ``` @@ -134,6 +154,8 @@ MKCOLA / HTTP/1.1 ```log off=0 message begin +off=0 len=5 span[method]="MKCOL" +off=5 method complete off=5 error code=6 reason="Expected space after method" ``` @@ -150,8 +172,12 @@ name ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=20 error code=10 reason="Invalid header token" ``` @@ -169,8 +195,12 @@ Accept-Encoding: gzip ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=4 span[header_field]="Host" off=21 header_field complete off=22 len=15 span[header_value]="www.example.com" @@ -192,8 +222,12 @@ Accept-Encoding: gzip ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=4 span[header_field]="Host" off=21 header_field complete off=22 len=15 span[header_value]="www.example.com" @@ -219,8 +253,12 @@ Host: localhost ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=4 span[header_field]="Host" off=21 header_field complete off=22 len=9 span[header_value]="localhost" @@ -240,8 +278,11 @@ GET / HTTP/5.6 ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="5.6" off=14 error code=9 reason="Invalid HTTP version" ``` @@ -255,7 +296,11 @@ GET / HTTP/1.1 ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=17 error code=30 reason="Unexpected space after start line" ``` \ No newline at end of file diff --git a/test/request/lenient-headers.md b/test/request/lenient-headers.md index eb0de421..b22874dc 100644 --- a/test/request/lenient-headers.md +++ b/test/request/lenient-headers.md @@ -15,8 +15,12 @@ Header1: \f ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=7 span[header_field]="Header1" off=27 header_field complete off=28 len=1 span[header_value]="\f" @@ -41,8 +45,12 @@ Header1: \f ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=7 span[header_field]="Header1" off=27 header_field complete off=28 len=4 span[header_value]="Okay" @@ -51,8 +59,12 @@ off=36 headers complete method=1 v=1/1 flags=0 content_length=0 off=36 message complete off=38 reset off=38 message begin +off=38 len=3 span[method]="GET" +off=41 method complete off=42 len=4 span[url]="/url" off=47 url complete +off=52 len=3 span[version]="1.1" +off=55 version complete off=57 len=7 span[header_field]="Header1" off=65 header_field complete off=66 len=1 span[header_value]="\f" @@ -74,8 +86,12 @@ Header1: \f ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=7 span[header_field]="Header1" off=27 header_field complete off=28 error code=10 reason="Invalid header value char" diff --git a/test/request/lenient-version.md b/test/request/lenient-version.md index 7fae4e2b..dbe360c6 100644 --- a/test/request/lenient-version.md +++ b/test/request/lenient-version.md @@ -12,8 +12,12 @@ GET / HTTP/5.6 ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url 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 off=18 message complete ``` \ No newline at end of file diff --git a/test/request/method.md b/test/request/method.md index 60dcd8cb..dce262e6 100644 --- a/test/request/method.md +++ b/test/request/method.md @@ -12,8 +12,12 @@ REPORT /test HTTP/1.1 ```log off=0 message begin +off=0 len=6 span[method]="REPORT" +off=6 method complete off=7 len=5 span[url]="/test" off=13 url 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 off=25 message complete ``` @@ -32,8 +36,12 @@ and yet even more data ```log off=0 message begin +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=38 len=3 span[version]="1.0" +off=41 version complete off=43 len=10 span[header_field]="User-agent" off=54 header_field complete off=55 len=12 span[header_value]="Mozilla/1.1N" @@ -60,8 +68,12 @@ Proxy-authorization: basic aGVsbG86d29ybGQ= ```log off=0 message begin +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=36 len=3 span[version]="1.0" +off=39 version complete off=41 len=10 span[header_field]="User-agent" off=52 header_field complete off=53 len=12 span[header_value]="Mozilla/1.1N" @@ -89,8 +101,12 @@ blarfcicle" ```log off=0 message begin +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=29 len=3 span[version]="1.0" +off=32 version complete off=34 len=10 span[header_field]="User-agent" off=45 header_field complete off=46 len=12 span[header_value]="Mozilla/1.1N" @@ -122,8 +138,12 @@ ST: "ssdp:all" ```log off=0 message begin +off=0 len=8 span[method]="M-SEARCH" +off=8 method complete off=9 len=1 span[url]="*" off=11 url complete +off=16 len=3 span[version]="1.1" +off=19 version complete off=21 len=4 span[header_field]="HOST" off=26 header_field complete off=27 len=20 span[header_value]="239.255.255.250:1900" @@ -155,8 +175,12 @@ cccccccccc ```log off=0 message begin +off=0 len=5 span[method]="PATCH" +off=5 method complete off=6 len=9 span[url]="/file.txt" off=16 url complete +off=21 len=3 span[version]="1.1" +off=24 version complete off=26 len=4 span[header_field]="Host" off=31 header_field complete off=32 len=15 span[header_value]="www.example.com" @@ -190,8 +214,12 @@ Host: www.example.com ```log off=0 message begin +off=0 len=5 span[method]="PURGE" +off=5 method complete off=6 len=9 span[url]="/file.txt" off=16 url complete +off=21 len=3 span[version]="1.1" +off=24 version complete off=26 len=4 span[header_field]="Host" off=31 header_field complete off=32 len=15 span[header_value]="www.example.com" @@ -212,8 +240,12 @@ Host: www.example.com ```log off=0 message begin +off=0 len=6 span[method]="SEARCH" +off=6 method complete off=7 len=1 span[url]="/" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=4 span[header_field]="Host" off=24 header_field complete off=25 len=15 span[header_value]="www.example.com" @@ -236,8 +268,12 @@ Link: ; rel="tag" ```log off=0 message begin +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=29 len=3 span[version]="1.1" +off=32 version complete off=34 len=4 span[header_field]="Host" off=39 header_field complete off=40 len=11 span[header_value]="example.com" @@ -267,8 +303,12 @@ Link: ; rel="tag" ```log off=0 message begin +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=31 len=3 span[version]="1.1" +off=34 version complete off=36 len=4 span[header_field]="Host" off=41 header_field complete off=42 len=11 span[header_value]="example.com" @@ -293,8 +333,12 @@ Host: example.com ```log off=0 message begin +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=31 len=3 span[version]="1.1" +off=34 version complete off=36 len=4 span[header_field]="Host" off=41 header_field complete off=42 len=11 span[header_value]="example.com" @@ -315,8 +359,12 @@ Host: example.com ```log off=0 message begin +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=30 len=3 span[version]="1.0" +off=33 version complete off=35 len=4 span[header_field]="Host" off=40 header_field complete off=41 len=11 span[header_value]="example.com" @@ -339,8 +387,12 @@ Host: example.com ```log off=0 message begin +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=32 len=3 span[version]="1.0" +off=35 version complete off=37 len=4 span[header_field]="Host" off=42 header_field complete off=43 len=11 span[header_value]="example.com" @@ -361,8 +413,12 @@ Host: example.com ```log off=0 message begin +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 len=3 span[version]="1.0" +off=36 version complete off=38 len=4 span[header_field]="Host" off=43 header_field complete off=44 len=11 span[header_value]="example.com" @@ -384,7 +440,11 @@ SM ```log off=0 message begin +off=0 len=3 span[method]="PRI" +off=3 method complete off=4 len=1 span[url]="*" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=24 error code=23 reason="Pause on PRI/Upgrade" ``` diff --git a/test/request/pausing.md b/test/request/pausing.md index 64ff4a8d..cc72beea 100644 --- a/test/request/pausing.md +++ b/test/request/pausing.md @@ -14,8 +14,12 @@ abc ```log off=0 message begin off=0 pause +off=0 len=4 span[method]="POST" +off=4 method complete off=5 len=1 span[url]="/" off=7 url complete +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" @@ -37,8 +41,12 @@ 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=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" @@ -49,6 +57,34 @@ off=41 message complete off=41 pause ``` +### on_method_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=4 pause +off=5 len=1 span[url]="/" +off=7 url complete +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_url_complete @@ -61,9 +97,41 @@ 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 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_version_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=12 len=3 span[version]="1.1" +off=15 version complete +off=15 pause off=17 len=14 span[header_field]="Content-Length" off=32 header_field complete off=33 len=1 span[header_value]="3" @@ -85,8 +153,12 @@ 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=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=32 pause @@ -109,8 +181,12 @@ 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=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" @@ -133,8 +209,12 @@ 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=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" @@ -161,8 +241,12 @@ a ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=17 span[header_field]="Transfer-Encoding" off=34 header_field complete off=35 len=7 span[header_value]="chunked" @@ -194,8 +278,12 @@ a ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=17 span[header_field]="Transfer-Encoding" off=34 header_field complete off=35 len=7 span[header_value]="chunked" diff --git a/test/request/pipelining.md b/test/request/pipelining.md index 94fad05f..bdfe6ab1 100644 --- a/test/request/pipelining.md +++ b/test/request/pipelining.md @@ -21,8 +21,12 @@ CCCC ```log off=0 message begin +off=0 len=4 span[method]="POST" +off=4 method complete off=5 len=4 span[url]="/aaa" off=10 url complete +off=15 len=3 span[version]="1.1" +off=18 version complete off=20 len=14 span[header_field]="Content-Length" off=35 header_field complete off=36 len=1 span[header_value]="3" @@ -32,8 +36,12 @@ off=41 len=3 span[body]="AAA" off=44 message complete off=46 reset off=46 message begin +off=46 len=3 span[method]="PUT" +off=49 method complete off=50 len=4 span[url]="/bbb" off=55 url complete +off=60 len=3 span[version]="1.1" +off=63 version complete off=65 len=14 span[header_field]="Content-Length" off=80 header_field complete off=81 len=1 span[header_value]="4" @@ -43,8 +51,12 @@ off=86 len=4 span[body]="BBBB" off=90 message complete off=92 reset off=92 message begin +off=92 len=5 span[method]="PATCH" +off=97 method complete off=98 len=4 span[url]="/ccc" off=103 url complete +off=108 len=3 span[version]="1.1" +off=111 version complete off=113 len=14 span[header_field]="Content-Length" off=128 header_field complete off=129 len=1 span[header_value]="5" diff --git a/test/request/sample.md b/test/request/sample.md index 61d224a2..a95489a4 100644 --- a/test/request/sample.md +++ b/test/request/sample.md @@ -16,8 +16,12 @@ Header2:\t Value2 ```log off=0 message begin +off=0 len=7 span[method]="OPTIONS" +off=7 method complete off=8 len=4 span[url]="/url" off=13 url complete +off=18 len=3 span[version]="1.1" +off=21 version complete off=23 len=7 span[header_field]="Header1" off=31 header_field complete off=32 len=6 span[header_value]="Value1" @@ -37,7 +41,7 @@ There's a optimization in `start_req_or_res` that passes execution to with `HTTP/`). However, there're still methods like `HEAD` that should get to `start_req`. Verify that it still works after optimization. - + ```http HEAD /url HTTP/1.1 @@ -46,8 +50,12 @@ HEAD /url HTTP/1.1 ```log off=0 message begin +off=0 len=4 span[method]="HEAD" +off=4 method complete off=5 len=4 span[url]="/url" off=10 url 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 off=22 message complete ``` @@ -66,8 +74,12 @@ Accept: */* ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=5 span[url]="/test" off=10 url complete +off=15 len=3 span[version]="1.1" +off=18 version complete off=20 len=10 span[header_field]="User-Agent" off=31 header_field complete off=32 len=85 span[header_value]="curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" @@ -103,8 +115,12 @@ Connection: keep-alive ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=12 span[url]="/favicon.ico" off=17 url complete +off=22 len=3 span[version]="1.1" +off=25 version complete off=27 len=4 span[header_field]="Host" off=32 header_field complete off=33 len=12 span[header_value]="0.0.0.0=5000" @@ -153,8 +169,12 @@ aaaaaaaaaaaaa:++++++++++ ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=9 span[url]="/dumbpack" off=14 url complete +off=19 len=3 span[version]="1.1" +off=22 version complete off=24 len=13 span[header_field]="aaaaaaaaaaaaa" off=38 header_field complete off=38 len=10 span[header_value]="++++++++++" @@ -174,8 +194,12 @@ GET /get_no_headers_no_body/world HTTP/1.1 ```log off=0 message begin +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=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 off=46 message complete ``` @@ -192,8 +216,12 @@ Accept: */* ```log off=0 message begin +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=33 len=3 span[version]="1.1" +off=36 version complete off=38 len=6 span[header_field]="Accept" off=45 header_field complete off=46 len=3 span[header_value]="*/*" @@ -219,8 +247,12 @@ Accept: */* ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=5 span[url]="/test" off=10 url complete +off=15 len=3 span[version]="1.0" +off=18 version complete off=20 len=4 span[header_field]="Host" off=25 header_field complete off=26 len=12 span[header_value]="0.0.0.0:5000" @@ -251,8 +283,12 @@ will send an extra CRLF before the next request. ```log off=2 message begin +off=2 len=3 span[method]="GET" +off=5 method complete off=6 len=5 span[url]="/test" off=12 url 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 off=24 message complete ``` @@ -268,6 +304,8 @@ GET / ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=7 url complete off=9 headers complete method=1 v=0/9 flags=0 content_length=0 @@ -298,8 +336,12 @@ Connection: ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=5 span[header_field]="Line1" off=22 header_field complete off=25 len=3 span[header_value]="abc" @@ -352,8 +394,12 @@ Connection:\n\ ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=15 len=5 span[header_field]="Line1" off=21 header_field complete off=24 len=3 span[header_value]="abc" @@ -372,8 +418,12 @@ Header1: Value1 ```log off=2 message begin +off=2 len=3 span[method]="GET" +off=5 method complete off=6 len=4 span[url]="/url" off=11 url complete +off=16 len=3 span[version]="1.1" +off=19 version complete off=21 len=7 span[header_field]="Header1" off=29 header_field complete off=30 len=6 span[header_value]="Value1" @@ -396,8 +446,12 @@ Test: Düsseldorf ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=4 span[header_field]="Test" off=21 header_field complete off=22 len=11 span[header_value]="Düsseldorf" @@ -421,8 +475,12 @@ Header2: \xffValue2 ```log off=0 message begin +off=0 len=7 span[method]="OPTIONS" +off=7 method complete off=8 len=4 span[url]="/url" off=13 url complete +off=18 len=3 span[version]="1.1" +off=21 version complete off=23 len=7 span[header_field]="Header1" off=31 header_field complete off=32 len=6 span[header_value]="Value1" @@ -480,8 +538,12 @@ X-SSL-Nonsense: -----BEGIN CERTIFICATE----- ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=1 span[url]="/" off=6 url complete +off=11 len=3 span[version]="1.1" +off=14 version complete off=16 len=14 span[header_field]="X-SSL-Nonsense" off=31 header_field complete off=34 len=27 span[header_value]="-----BEGIN CERTIFICATE-----" diff --git a/test/request/transfer-encoding.md b/test/request/transfer-encoding.md index 53831602..89dc3fd8 100644 --- a/test/request/transfer-encoding.md +++ b/test/request/transfer-encoding.md @@ -15,8 +15,12 @@ Transfer-Encoding: chunked ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" off=37 header_field complete off=38 len=7 span[header_value]="chunked" @@ -40,8 +44,12 @@ a ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" off=37 header_field complete off=38 len=7 span[header_value]="chunked" @@ -71,8 +79,12 @@ A ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" off=37 header_field complete off=38 len=7 span[header_value]="chunked" @@ -102,8 +114,12 @@ all your base are belong to us ```log off=0 message begin +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=38 len=3 span[version]="1.1" +off=41 version complete off=43 len=17 span[header_field]="Transfer-Encoding" off=61 header_field complete off=62 len=7 span[header_value]="chunked" @@ -135,8 +151,12 @@ hello ```log off=0 message begin +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=36 len=3 span[version]="1.1" +off=39 version complete off=41 len=17 span[header_field]="Transfer-Encoding" off=59 header_field complete off=60 len=7 span[header_value]="chunked" @@ -173,8 +193,12 @@ Content-Type: text/plain ```log off=0 message begin +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=38 len=3 span[version]="1.1" +off=41 version complete off=43 len=17 span[header_field]="Transfer-Encoding" off=61 header_field complete off=62 len=7 span[header_value]="chunked" @@ -216,8 +240,12 @@ hello ```log off=0 message begin +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=43 len=3 span[version]="1.1" +off=46 version complete off=48 len=17 span[header_field]="Transfer-Encoding" off=66 header_field complete off=67 len=7 span[header_value]="chunked" @@ -249,8 +277,12 @@ aa ```log off=0 message begin +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=43 len=3 span[version]="1.1" +off=46 version complete off=48 len=4 span[header_field]="Host" off=53 header_field complete off=54 len=9 span[header_value]="localhost" @@ -278,8 +310,12 @@ Transfer-Encoding: pigeons ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" off=37 header_field complete off=38 len=7 span[header_value]="pigeons" @@ -302,8 +338,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -339,8 +379,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -370,8 +414,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -396,8 +444,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -425,8 +477,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -453,8 +509,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -488,8 +548,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -525,8 +589,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -565,8 +633,12 @@ World ```log off=0 message begin +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=49 len=3 span[version]="1.1" +off=52 version complete off=54 len=6 span[header_field]="Accept" off=61 header_field complete off=62 len=3 span[header_value]="*/*" @@ -594,8 +666,12 @@ foo ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" off=37 header_field complete off=38 len=7 span[header_value]="chunked" @@ -622,8 +698,12 @@ foo ```log off=0 message begin +off=0 len=3 span[method]="PUT" +off=3 method complete off=4 len=4 span[url]="/url" off=9 url complete +off=14 len=3 span[version]="1.1" +off=17 version complete off=19 len=17 span[header_field]="Transfer-Encoding" off=37 header_field complete off=38 len=7 span[header_value]="chunked" diff --git a/test/request/uri.md b/test/request/uri.md index 5e02c3e2..356863e6 100644 --- a/test/request/uri.md +++ b/test/request/uri.md @@ -12,8 +12,12 @@ GET /with_"lovely"_quotes?foo=\"bar\" HTTP/1.1 ```log off=0 message begin +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=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 off=50 message complete ``` @@ -31,8 +35,12 @@ GET /test.cgi?foo=bar?baz HTTP/1.1 ```log off=0 message begin +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=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 off=38 message complete ``` @@ -48,8 +56,12 @@ GET http://hypnotoad.org?hail=all HTTP/1.1\r\n ```log off=0 message begin +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=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 off=46 message complete ``` @@ -65,8 +77,12 @@ GET http://hypnotoad.org:1234?hail=all HTTP/1.1 ```log off=0 message begin +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=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 off=51 message complete ``` @@ -86,8 +102,12 @@ GET /test.cgi?query=| HTTP/1.1 ```log off=0 message begin +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=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 off=34 message complete ``` @@ -103,8 +123,12 @@ GET http://hypnotoad.org:1234 HTTP/1.1 ```log off=0 message begin +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=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 off=42 message complete ``` @@ -121,8 +145,12 @@ Host: github.com ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=4 len=36 span[url]="/δ¶/δt/космос/pope?q=1#narf" off=41 url complete +off=46 len=3 span[version]="1.1" +off=49 version complete off=51 len=4 span[header_field]="Host" off=56 header_field complete off=57 len=10 span[header_value]="github.com" @@ -143,6 +171,8 @@ Host: github.com ```log off=0 message begin +off=0 len=3 span[method]="GET" +off=3 method complete off=5 error code=7 reason="Invalid char in url path" ``` @@ -157,8 +187,12 @@ GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1 ```log off=0 message begin +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=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 off=57 message complete ``` @@ -176,8 +210,12 @@ Proxy-authorization: basic aGVsbG86d29ybGQ= ```log off=0 message begin +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=37 len=3 span[version]="1.0" +off=40 version complete off=42 len=10 span[header_field]="User-agent" off=53 header_field complete off=54 len=12 span[header_value]="Mozilla/1.1N" @@ -202,8 +240,12 @@ GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1 ```log off=0 message begin +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=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 off=58 message complete ``` @@ -219,6 +261,8 @@ GET /foo bar/ HTTP/1.1 ```log off=0 message begin +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/" diff --git a/test/response/connection.md b/test/response/connection.md index 2d2552fb..4457743a 100644 --- a/test/response/connection.md +++ b/test/response/connection.md @@ -16,6 +16,8 @@ hello world ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=12 span[header_field]="Content-Type" @@ -54,6 +56,8 @@ HTTP/1.0 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.0" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=10 span[header_field]="Connection" @@ -78,6 +82,8 @@ HTTP/1.0 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.0" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete off=25 len=10 span[header_field]="Connection" @@ -88,6 +94,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=56 len=3 span[version]="1.0" +off=59 version complete off=64 len=2 span[status]="OK" ``` @@ -105,6 +113,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +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 @@ -124,12 +134,16 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete 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=32 len=3 span[version]="1.1" +off=35 version complete off=40 len=2 span[status]="OK" ``` @@ -145,6 +159,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete off=25 len=10 span[header_field]="Connection" @@ -171,6 +187,8 @@ Connection: close ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete off=25 len=14 span[header_field]="Content-Length" @@ -201,6 +219,8 @@ Connection: close ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete off=25 len=14 span[header_field]="Content-Length" @@ -232,6 +252,8 @@ Connection: close ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete off=25 len=14 span[header_field]="Content-Length" @@ -247,6 +269,8 @@ off=65 len=5 span[body]="2ad73" off=70 message complete off=70 reset off=70 message begin +off=75 len=3 span[version]="1.1" +off=78 version complete off=83 len=2 span[status]="OK" ``` @@ -262,6 +286,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=10 span[status]="No content" off=25 status complete off=25 len=10 span[header_field]="Connection" @@ -272,6 +298,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=51 len=3 span[version]="1.1" +off=54 version complete off=59 len=2 span[status]="OK" ``` @@ -290,6 +318,8 @@ proto ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=19 span[status]="Switching Protocols" off=34 status complete off=34 len=10 span[header_field]="Connection" @@ -330,6 +360,8 @@ proto ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=19 span[status]="Switching Protocols" off=34 status complete off=34 len=10 span[header_field]="Connection" @@ -370,6 +402,8 @@ body ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=10 span[header_field]="Connection" @@ -398,6 +432,8 @@ body ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=10 span[header_field]="Connection" @@ -437,6 +473,8 @@ dy ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=10 span[header_field]="Connection" diff --git a/test/response/content-length.md b/test/response/content-length.md index 48ef077b..0d1bb535 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=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=4 span[header_field]="Date" @@ -93,6 +95,8 @@ OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=16 span[header_field]="Content-Length-X" diff --git a/test/response/finish.md b/test/response/finish.md index 117ddb11..2938b83b 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=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 diff --git a/test/response/invalid.md b/test/response/invalid.md index c708c7f0..9ddc3fa9 100644 --- a/test/response/invalid.md +++ b/test/response/invalid.md @@ -28,6 +28,7 @@ HTTP/01.1 200 OK ```log off=0 message begin +off=5 len=1 span[version]="0" off=6 error code=9 reason="Expected dot" ``` @@ -42,6 +43,7 @@ HTTP/11.1 200 OK ```log off=0 message begin +off=5 len=1 span[version]="1" off=6 error code=9 reason="Expected dot" ``` @@ -56,8 +58,11 @@ HTTP/1.01 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.0" +off=8 version complete off=8 error code=9 reason="Expected space after version" ``` +--> ### Tab after HTTP version @@ -70,6 +75,8 @@ HTTP/1.1\t200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=8 error code=9 reason="Expected space after version" ``` @@ -84,6 +91,8 @@ off=8 error code=9 reason="Expected space after version" ```log off=1 message begin +off=6 len=3 span[version]="1.1" +off=9 version complete off=9 error code=9 reason="Expected space after version" ``` @@ -99,6 +108,8 @@ Foo: 1\rBar: 2 ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=3 span[header_field]="Foo" @@ -118,6 +129,7 @@ HTTP/5.6 200 OK ```log off=0 message begin +off=5 len=3 span[version]="5.6" off=8 error code=9 reason="Invalid HTTP version" ``` @@ -131,6 +143,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=18 error code=30 reason="Unexpected space after start line" diff --git a/test/response/lenient-version.md b/test/response/lenient-version.md index 94642b38..e0d154ab 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=5 len=3 span[version]="5.6" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=19 headers complete status=200 v=5/6 flags=0 content_length=0 diff --git a/test/response/pausing.md b/test/response/pausing.md index 1b5f5d3f..7aa17b8d 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=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=14 span[header_field]="Content-Length" @@ -37,6 +39,8 @@ abc ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=14 span[header_field]="Content-Length" @@ -49,6 +53,32 @@ off=41 message complete off=41 pause ``` +### on_version_complete + + +```http +HTTP/1.1 200 OK +Content-Length: 3 + +abc +``` + +```log +off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete +off=8 pause +off=13 len=2 span[status]="OK" +off=17 status 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 status=200 v=1/1 flags=20 content_length=3 +off=38 len=3 span[body]="abc" +off=41 message complete +``` + ### on_status_complete @@ -61,6 +91,8 @@ abc ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 pause @@ -85,6 +117,8 @@ abc ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=14 span[header_field]="Content-Length" @@ -109,6 +143,8 @@ abc ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=14 span[header_field]="Content-Length" @@ -133,6 +169,8 @@ abc ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=14 span[header_field]="Content-Length" @@ -161,6 +199,8 @@ a ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=17 span[header_field]="Transfer-Encoding" @@ -194,6 +234,8 @@ a ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=17 span[header_field]="Transfer-Encoding" diff --git a/test/response/pipelining.md b/test/response/pipelining.md index 26b2f190..01e007a9 100644 --- a/test/response/pipelining.md +++ b/test/response/pipelining.md @@ -21,6 +21,8 @@ CCCC ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=14 span[header_field]="Content-Length" @@ -32,6 +34,8 @@ off=38 len=3 span[body]="AAA" off=41 message complete off=43 reset off=43 message begin +off=48 len=3 span[version]="1.1" +off=51 version complete off=56 len=7 span[status]="Created" off=65 status complete off=65 len=14 span[header_field]="Content-Length" @@ -43,6 +47,8 @@ off=86 len=4 span[body]="BBBB" off=90 message complete off=92 reset off=92 message begin +off=97 len=3 span[version]="1.1" +off=100 version complete off=105 len=8 span[status]="Accepted" off=115 status complete off=115 len=14 span[header_field]="Content-Length" diff --git a/test/response/sample.md b/test/response/sample.md index a1c6e144..a34d8c23 100644 --- a/test/response/sample.md +++ b/test/response/sample.md @@ -15,6 +15,8 @@ Content-Length: 0 ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=7 span[header_field]="Header1" @@ -60,6 +62,8 @@ HTTP/1.1 200 OK ```log off=0 message begin +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 @@ -90,6 +94,8 @@ _(Note the `$` char in header field)_ ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=17 span[status]="Moved Permanently" off=32 status complete off=32 len=8 span[header_field]="Location" @@ -163,6 +169,8 @@ Transfer-Encoding: chunked ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=16 span[status]="MovedPermanently" off=31 status complete off=31 len=4 span[header_field]="Date" @@ -221,6 +229,8 @@ HTTP/1.1 404 Not Found ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=9 span[status]="Not Found" off=24 status complete off=26 headers complete status=404 v=1/1 flags=0 content_length=0 @@ -237,6 +247,8 @@ HTTP/1.1 301 ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=14 status complete off=16 headers complete status=301 v=1/1 flags=0 content_length=0 ``` @@ -252,6 +264,8 @@ HTTP/1.1 200 \r\n\ ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=15 status complete off=17 headers complete status=200 v=1/1 flags=0 content_length=0 ``` @@ -269,6 +283,8 @@ these headers are from http://news.ycombinator.com/ ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=16 status complete off=16 len=12 span[header_field]="Content-Type" @@ -294,6 +310,8 @@ DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=6 span[header_field]="Server" @@ -339,6 +357,8 @@ Connection: keep-alive ```log off=0 message begin +off=5 len=3 span[version]="1.0" +off=8 version complete off=13 len=17 span[status]="Moved Permanently" off=32 status complete off=32 len=4 span[header_field]="Date" @@ -405,6 +425,8 @@ Connection: close ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=4 span[header_field]="Date" @@ -475,6 +497,8 @@ Connection: keep-alive ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=6 span[header_field]="Server" @@ -508,6 +532,8 @@ Connection: keep-alive ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=6 span[header_field]="Server" @@ -557,6 +583,8 @@ Connection: close ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=19 span[status]="Oriëntatieprobleem" off=34 status complete off=34 len=4 span[header_field]="Date" @@ -586,6 +614,8 @@ HTTP/0.9 200 OK ```log off=0 message begin +off=5 len=3 span[version]="0.9" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=19 headers complete status=200 v=0/9 flags=0 content_length=0 @@ -607,6 +637,8 @@ hello world ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=12 span[header_field]="Content-Type" @@ -631,6 +663,8 @@ Content-Length: 0 ```log off=2 message begin +off=7 len=3 span[version]="1.1" +off=10 version complete off=15 len=2 span[status]="OK" off=19 status complete off=19 len=7 span[header_field]="Header1" diff --git a/test/response/transfer-encoding.md b/test/response/transfer-encoding.md index b606c660..c7ddd67b 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=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=12 span[header_field]="Content-Type" @@ -49,6 +51,8 @@ World ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=6 span[header_field]="Accept" @@ -77,6 +81,8 @@ World ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=6 span[header_field]="Accept" @@ -114,6 +120,8 @@ OK ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=6 span[header_field]="Accept" @@ -155,6 +163,8 @@ aa ```log off=0 message begin +off=5 len=3 span[version]="1.1" +off=8 version complete off=13 len=2 span[status]="OK" off=17 status complete off=17 len=4 span[header_field]="Host"