You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deps/llhttp/README.md
+235Lines changed: 235 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,239 @@ if (err == HPE_OK) {
92
92
```
93
93
For more information on API usage, please refer to [src/native/api.h](https://github.com/nodejs/llhttp/blob/main/src/native/api.h).
94
94
95
+
## API
96
+
97
+
### llhttp_settings_t
98
+
99
+
The settings object contains a list of callbacks that the parser will invoke.
100
+
101
+
The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_PAUSED` (pause the parser):
102
+
103
+
* `on_message_begin`: Invoked when a new request/response starts.
104
+
* `on_message_complete`: Invoked when a request/response has been completedly parsed.
105
+
* `on_url_complete`: Invoked after the URL has been parsed.
106
+
* `on_method_complete`: Invoked after the HTTP method has been parsed.
107
+
* `on_version_complete`: Invoked after the HTTP version has been parsed.
108
+
* `on_status_complete`: Invoked after the status code has been parsed.
109
+
* `on_header_field_complete`: Invoked after a header name has been parsed.
110
+
* `on_header_value_complete`: Invoked after a header value has been parsed.
111
+
* `on_chunk_header`: Invoked after a new chunk is started. The current chunk length is stored in `parser->content_length`.
112
+
* `on_chunk_extension_name_complete`: Invoked after a chunk extension name is started.
113
+
* `on_chunk_extension_value_complete`: Invoked after a chunk extension value is started.
114
+
* `on_chunk_complete`: Invoked after a new chunk is received.
115
+
* `on_reset`: Invoked after `on_message_complete` and before `on_message_begin` when a new message
116
+
is received on the same parser. This is not invoked for the first message of the parser.
117
+
118
+
The following callbacks can return `0` (proceed normally), `-1` (error) or `HPE_USER` (error from the callback):
119
+
120
+
* `on_url`: Invoked when another character of the URL is received.
121
+
* `on_status`: Invoked when another character of the status is received.
122
+
* `on_method`: Invoked when another character of the method is received.
123
+
When parser is created with `HTTP_BOTH` and the input is a response, this also invoked for the sequence `HTTP/`
124
+
of the first message.
125
+
* `on_version`: Invoked when another character of the version is received.
126
+
* `on_header_field`: Invoked when another character of a header name is received.
127
+
* `on_header_value`: Invoked when another character of a header value is received.
128
+
* `on_chunk_extension_name`: Invoked when another character of a chunk extension name is received.
129
+
* `on_chunk_extension_value`: Invoked when another character of a extension value is received.
130
+
131
+
The callback `on_headers_complete`, invoked when headers are completed, can return:
132
+
133
+
* `0`: Proceed normally.
134
+
* `1`: Assume that request/response has no body, and proceed to parsing the next message.
135
+
* `2`: Assume absence of body (as above) and make `llhttp_execute()` return `HPE_PAUSED_UPGRADE`.
0 commit comments