mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-06 08:03:34 +07:00
It would be probably good idea to also remove tools/docgen.py and asciidoc.mk, but asciidoc.mk is still mentioned under `cloud/doc`, which may contain some useful info which we'll need at least to review before removing. PUBLISHED_FROM=faf454d4c52a2f07ea8ac084cf0bd11a0c9c9b3b
2.5 KiB
2.5 KiB
title, decl_name, symbol_kind, signature
| title | decl_name | symbol_kind | signature |
|---|---|---|---|
| mg_set_protocol_http_websocket() | mg_set_protocol_http_websocket | func | void mg_set_protocol_http_websocket(struct mg_connection *nc); |
Attach built-in HTTP event handler to the given connection. User-defined event handler will receive following extra events:
- MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request
is passed as
struct http_messagethrough the handler'svoid *ev_datapointer. - MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has received. This event is sent before body is parsed. After this user should expect a sequence of MG_EV_HTTP_PART_BEGIN/DATA/END requests. This is also the last time when headers and other request fields are accessible.
- MG_EV_HTTP_REPLY: HTTP reply has arrived. Parsed HTTP reply is passed as
struct http_messagethrough the handler'svoid *ev_datapointer. - MG_EV_HTTP_CHUNK: HTTP chunked-encoding chunk has arrived.
Parsed HTTP reply is passed as
struct http_messagethrough the handler'svoid *ev_datapointer.http_message::bodywould contain incomplete, reassembled HTTP body. It will grow with every new chunk arrived, and potentially can consume a lot of memory. An event handler may process the body as chunks are coming, and signal Mongoose to delete processed body by settingMG_F_DELETE_CHUNKinmg_connection::flags. When the last zero chunk is received, Mongoose sendsMG_EV_HTTP_REPLYevent with full reassembled body (if handler did not signal to delete chunks) or with empty body (if handler did signal to delete chunks). - MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received websocket handshake
request.
ev_datacontains parsed HTTP request. - MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed Websocket handshake.
ev_dataisNULL. - MG_EV_WEBSOCKET_FRAME: new websocket frame has arrived.
ev_dataisstruct websocket_message * - MG_EV_HTTP_PART_BEGIN: new part of multipart message is started, extra parameters are passed in mg_http_multipart_part
- MG_EV_HTTP_PART_DATA: new portion of data from multiparted message no additional headers are available, only data and data size
- MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to find the end of packet Note: Mongoose should be compiled with MG_ENABLE_HTTP_STREAMING_MULTIPART to enable MG_EV_HTTP_MULTIPART_REQUEST, MG_EV_HTTP_REQUEST_END, MG_EV_HTTP_REQUEST_CANCEL, MG_EV_HTTP_PART_BEGIN, MG_EV_HTTP_PART_DATA, MG_EV_HTTP_PART_END constants