The module exports several constants (*
is used to denote a family prefix):
FLAG_DEBUG
: If the debug informations are enabled or not.MESSAGE_TYPE_*
: The type of the parser: it can autodetect (default) or only parse requests or response.ERROR_*
: An error code.METHOD_*
: An HTTP/RTSP request method.CONNECTION_*
: AConnection
header value.CALLBACK_*
: A parser callback.STATE_*
: A parser state.
All callback in Milo have the following signature (TypeScript syntax):
(parser: number, offset: number, length: number) => void
where the parameters have the following meaning:
- The current parser.
- The payload offset. Can be
0
. - The data length. Can be
0
.
If both offset and length are 0
, it means the callback has no payload associated.
An enum listing all possible message types.
Access is supported from string constant or numeric value.
An enum listing all possible parser errors.
Access is supported from string constant or numeric value.
An enum listing all possible HTTP/RTSP methods.
Access is supported from string constant or numeric value.
An enum listing all possible connection (Connection
header value) types.
Access is supported from string constant or numeric value.
An enum listing all possible parser callbacks.
Access is supported from string constant or numeric value.
An enum listing all possible parser states.
Access is supported from string constant or numeric value.
Allocates a shared memory area with the WebAssembly instance which can be used to pass data to the parser.
The returned value MUST be destroyed later using dealloc
.
Deallocates a shared memory area created with alloc
.
Creates a new parser.
The returned value MUST be destroyed later using destroy
.
Destroys a parser.
Parses data
up to limit
characters.
It returns the number of consumed characters.
Resets a parser. The second parameters specifies if to also reset the parsed counter.
The following fields are not modified:
position
context
mode
manage_unconsumed
continue_without_data
context
Clears all values about the message in the parser.
The connection and message type fields are not cleared.
Pauses the parser. The parser will have to be resumed via resume
.
Resumes the parser.
Marks the parser as finished. Any new invocation of milo::milo_parse
will put the parser in the error state.
Marks the parsing a failed, setting a error code and and error message.
Returns the parser mode.
Returns true
if the parser is paused.
Returns true
if the parser should automatically copy and prepend unconsumed data.
Returns true
if the next execution of the parse loop should execute even if there is no more data.
Returns true
if the current request used CONNECT
method.
Returns true
if the parser should skip the body.
Returns the parser state.
Returns the parser position.
Returns the total bytes consumed from this parser.
Returns the parser error.
Returns the parser current message type.
Returns the parser current request method.
Returns the parser current response status.
Returns the parser current message HTTP version major version.
Returns the parser current message HTTP version minor version.
Returns the parser value for the connection header.
Returns the parser value of the Content-Length
header.
Returns the parser expected length of the next chunk.
Returns the parser missing data length of the body according to the content_length
field.
Returns the parser missing data length of the next chunk according to to the chunk_size
field.
Returns true
if the parser the current message has a Content-Length
header.
Returns true
if the parser the current message has a Transfer-Encoding: chunked
header.
Returns true
if the parser the current message has a Connection: upgrade
header.
Returns true
if the parser the current message has a Trailers
header.
Returns the parser error description or null
.
Returns the parser callback error or null
.
Sets the parser mode.
Sets if the parser should automatically copy and prepend unconsumed data.
Sets if the next execution of the parse loop should execute even if there is no more data.
Set if the parser should skip the body.
Sets if the current request used the CONNECT
method.
Sets the parser before_state_change
callback.
Sets the parser after_state_change
callback.
Sets the parser on_error
callback.
Sets the parser on_finish
callback.
Sets the parser on_message_start
callback.
Sets the parser on_message_complete
callback.
Sets the parser on_request
callback.
Sets the parser on_response
callback.
Sets the parser on_reset
callback.
Sets the parser on_method
callback.
Sets the parser on_url
callback.
Sets the parser on_protocol
callback.
Sets the parser on_version
callback.
Sets the parser on_status
callback.
Sets the parser on_reason
callback.
Sets the parser on_header_name
callback.
Sets the parser on_header_value
callback.
Sets the parser on_headers
callback.
Sets the parser on_connect
callback.
Sets the parser on_upgrade
callback.
Sets the parser on_chunk_length
callback.
Sets the parser on_chunk_extension_name
callback.
Sets the parser on_chunk_extension_value
callback.
Sets the parser on_chunk
callback.
Sets the parser on_body
callback.
Sets the parser on_data
callback.
Sets the parser on_trailer_name
callback.
Sets the parser on_trailer_value
callback.
Sets the parser on_trailers
callback.