@@ -94,7 +94,7 @@ int main() {
94
94
if (err == HPE_OK) {
95
95
fprintf(stdout, "Successfully parsed!\n");
96
96
} else {
97
- fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), parser.reason );
97
+ fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), llhttp_get_error_reason(& parser) );
98
98
}
99
99
}
100
100
```
@@ -112,6 +112,7 @@ The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_
112
112
* `on_message_complete`: Invoked when a request/response has been completedly parsed.
113
113
* `on_url_complete`: Invoked after the URL has been parsed.
114
114
* `on_method_complete`: Invoked after the HTTP method has been parsed.
115
+ * `on_protocol_complete`: Invoked after the HTTP version has been parsed.
115
116
* `on_version_complete`: Invoked after the HTTP version has been parsed.
116
117
* `on_status_complete`: Invoked after the status code has been parsed.
117
118
* `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_
130
131
* `on_method`: Invoked when another character of the method is received.
131
132
When parser is created with `HTTP_BOTH` and the input is a response, this also invoked for the sequence `HTTP/`
132
133
of the first message.
134
+ * `on_protocol`: Invoked when another character of the protocol is received.
133
135
* `on_version`: Invoked when another character of the version is received.
134
136
* `on_header_field`: Invoked when another character of a header name is received.
135
137
* `on_header_value`: Invoked when another character of a header value is received.
@@ -187,7 +189,8 @@ Parse full or partial request/response, invoking user callbacks along the way.
187
189
188
190
If any of `llhttp_data_cb` returns errno not equal to `HPE_OK` - the parsing interrupts,
189
191
and such errno is returned from `llhttp_execute()`. If `HPE_PAUSED` was used as a errno,
190
- the execution can be resumed with `llhttp_resume()` call.
192
+ the execution can be resumed with `llhttp_resume()` call. In that case the input should be advanced
193
+ to the last processed byte from the parser, which can be obtained via `llhttp_get_error_pos()`.
191
194
192
195
In a special case of CONNECT/Upgrade request/response `HPE_PAUSED_UPGRADE` is returned
193
196
after fully parsing the request/response. If the user wishes to continue parsing,
@@ -196,6 +199,8 @@ they need to invoke `llhttp_resume_after_upgrade()`.
196
199
**if this function ever returns a non-pause type error, it will continue to return
197
200
the same error upon each successive call up until `llhttp_init()` is called.**
198
201
202
+ If this function returns `HPE_OK`, it means all the input has been consumed and parsed.
203
+
199
204
### `llhttp_errno_t llhttp_finish(llhttp_t* parser)`
200
205
201
206
This method should be called when the other side has no further bytes to
0 commit comments