Commit 9101cd03 authored by Alexander Alashkin's avatar Alexander Alashkin Committed by Cesanta Bot

Use lld for ID

PUBLISHED_FROM=1246247fc29eb9a75b986ff7bb2d2350a52c03fc
parent 4b2d3f5f
......@@ -10,13 +10,13 @@ signature: |
const char *post_data);
---
Helper function that creates an outbound HTTP connection.
Helper function that creates outbound HTTP connection.
`url` is a URL to fetch. It must be properly URL-encoded, e.g. have
no spaces, etc. By default, `mg_connect_http()` sends the Connection and
Host headers. `extra_headers` is an extra HTTP header to send, e.g.
no spaces, etc. By default, `mg_connect_http()` sends Connection and
Host headers. `extra_headers` is an extra HTTP headers to send, e.g.
`"User-Agent: my-app\r\n"`.
If `post_data` is NULL, then a GET request is created. Otherwise, a POST request
If `post_data` is NULL, then GET request is created. Otherwise, POST request
is created with the specified POST data. Note that if the data being posted
is a form submission, the `Content-Type` header should be set accordingly
(see example below).
......
......@@ -11,8 +11,8 @@ signature: |
const char *post_data);
---
Helper function that creates an outbound HTTP connection.
Helper function that creates outbound HTTP connection.
Mostly identical to mg_connect_http, but allows you to provide extra parameters
(for example, SSL parameters)
Mostly identical to mg_connect_http, but allows to provide extra parameters
(for example, SSL parameters
......@@ -13,7 +13,7 @@ Helper function that creates an outbound WebSocket connection.
`url` is a URL to connect to. It must be properly URL-encoded, e.g. have
no spaces, etc. By default, `mg_connect_ws()` sends Connection and
Host headers. `extra_headers` is an extra HTTP header to send, e.g.
Host headers. `extra_headers` is an extra HTTP headers to send, e.g.
`"User-Agent: my-app\r\n"`.
If `protocol` is not NULL, then a `Sec-WebSocket-Protocol` header is sent.
......
......@@ -12,6 +12,6 @@ signature: |
Helper function that creates an outbound WebSocket connection
Mostly identical to `mg_connect_ws`, but allows to provide extra parameters
(for example, SSL parameters)
Mostly identical to mg_connect_ws, but allows to provide extra parameters
(for example, SSL parameters
......@@ -12,7 +12,7 @@ This handler can be used to implement file uploads with minimum code.
This handler will process MG_EV_HTTP_PART_* events and store file data into
a local file.
`local_name_fn` will be invoked with whatever name was provided by the client
and will expect the name of the local file to open. A return value of NULL will
and will expect the name of the local file to open. Return value of NULL will
abort file upload (client will get a "403 Forbidden" response). If non-null,
the returned string must be heap-allocated and will be freed by the caller.
Exception: it is ok to return the same string verbatim.
......
......@@ -6,7 +6,7 @@ signature: |
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
---
Searches and returns the header `name` in parsed HTTP message `hm`.
Search and return header `name` in parsed HTTP message `hm`.
If header is not found, NULL is returned. Example:
struct mg_str *host_hdr = mg_get_http_header(hm, "Host");
......
......@@ -7,10 +7,10 @@ signature: |
size_t dst_len);
---
Fetches a HTTP form variable.
Fetch an HTTP form variable.
Fetches a variable `name` from a `buf` into a buffer specified by
`dst`, `dst_len`. The destination is always zero-terminated. Returns the length
Fetch a variable `name` from a `buf` into a buffer specified by
`dst`, `dst_len`. Destination is always zero-terminated. Return length
of a fetched variable. If not found, 0 is returned. `buf` must be
valid url-encoded buffer. If destination is too small, `-1` is returned.
......@@ -7,6 +7,6 @@ signature: |
FILE *fp);
---
Authenticates a HTTP request against an opened password file.
Authenticate HTTP request against opened passwords file.
Returns 1 if authenticated, 0 otherwise.
......@@ -9,5 +9,5 @@ signature: |
const char *passwd);
---
Creates digest authentication header for a client request.
Create Digest authentication header for client request.
......@@ -7,17 +7,17 @@ signature: |
size_t buf_size);
---
Parses the HTTP header `hdr`. Finds variable `var_name` and stores its value
in the buffer `buf`, `buf_size`. Returns 0 if variable not found, non-zero
Parse HTTP header `hdr`. Find variable `var_name` and store it's value
in the buffer `buf`, `buf_size`. Return 0 if variable not found, non-zero
otherwise.
This function is supposed to parse
cookies, authentication headers, etc. Example (error handling omitted):
cookies, authentication headers, etcetera. Example (error handling omitted):
char user[20];
struct mg_str *hdr = mg_get_http_header(hm, "Authorization");
mg_http_parse_header(hdr, "username", user, sizeof(user));
Returns the length of the variable's value. If buffer is not large enough,
Return length of the variable's value. If buffer is not large enough,
or variable not found, 0 is returned.
......@@ -6,10 +6,10 @@ signature: |
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
---
Parses a HTTP message.
Parse a HTTP message.
`is_req` should be set to 1 if parsing a request, 0 if reply.
`is_req` should be set to 1 if parsing request, 0 if reply.
Returns the number of bytes parsed. If HTTP message is
incomplete `0` is returned. On parse error, a negative number is returned.
Return number of bytes parsed. If HTTP message is
incomplete, `0` is returned. On parse error, negative number is returned.
......@@ -9,13 +9,13 @@ signature: |
size_t *chunk_len);
---
Parses the buffer `buf`, `buf_len` that contains multipart form data chunks.
Stores the chunk name in a `var_name`, `var_name_len` buffer.
Parse buffer `buf`, `buf_len` that contains multipart form data chunks.
Store chunk name in a `var_name`, `var_name_len` buffer.
If a chunk is an uploaded file, then `file_name`, `file_name_len` is
filled with an uploaded file name. `chunk`, `chunk_len`
points to the chunk data.
Return: number of bytes to skip to the next chunk or 0 if there are
Return: number of bytes to skip to the next chunk, or 0 if there are
no more chunks.
Usage example:
......
......@@ -6,5 +6,5 @@ signature: |
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
---
Sends a printf-formatted HTTP chunk, escaping HTML tags.
Send printf-formatted HTTP chunk, escaping HTML tags.
......@@ -6,6 +6,6 @@ signature: |
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
---
Sends a printf-formatted HTTP chunk.
Send printf-formatted HTTP chunk.
Functionality is similar to `mg_send_http_chunk()`.
......@@ -7,8 +7,8 @@ signature: |
const char *fmt, ...);
---
Sends WebSocket frame to the remote end.
Send websocket frame to the remote end.
Like `mg_send_websocket_frame()`, but allows to create formatted messages
Like `mg_send_websocket_frame()`, but allows to create formatted message
with `printf()`-like semantics.
......@@ -7,8 +7,8 @@ signature: |
mg_event_handler_t handler);
---
Registers a callback for a specified http endpoint
Note: if callback is registered it is called instead of the
Register callback for specified http endpoint
Note: if callback is registered it is called instead of
callback provided in mg_bind
Example code snippet:
......
......@@ -7,15 +7,15 @@ signature: |
int64_t content_length, const char *extra_headers);
---
Sends a response line and headers.
This function sends a response line with the `status_code`, and automatically
sends one header: either "Content-Length" or "Transfer-Encoding".
Send response line and headers.
This function sends response line with the `status_code`, and automatically
sends one header: either "Content-Length", or "Transfer-Encoding".
If `content_length` is negative, then "Transfer-Encoding: chunked" header
is sent, otherwise, "Content-Length" header is sent.
NOTE: If `Transfer-Encoding` is `chunked`, then message body must be sent
using `mg_send_http_chunk()` or `mg_printf_http_chunk()` functions.
Otherwise, `mg_send()` or `mg_printf()` must be used.
Extra headers could be set through `extra_headers`. Note `extra_headers`
Extra headers could be set through `extra_headers` - and note `extra_headers`
must NOT be terminated by a new line.
......@@ -6,16 +6,16 @@ signature: |
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
---
Sends buffer `buf` of size `len` to the client using chunked HTTP encoding.
This function sends the buffer size as hex number + newline first, then
the buffer itself, then the newline. For example,
`mg_send_http_chunk(nc, "foo", 3)` whill append the `3\r\nfoo\r\n` string to
Send buffer `buf` of size `len` to the client using chunked HTTP encoding.
This function first sends buffer size as hex number + newline, then
buffer itself, then newline. For example,
`mg_send_http_chunk(nc, "foo", 3)` whill append `3\r\nfoo\r\n` string to
the `nc->send_mbuf` output IO buffer.
NOTE: The HTTP header "Transfer-Encoding: chunked" should be sent prior to
NOTE: HTTP header "Transfer-Encoding: chunked" should be sent prior to
using this function.
NOTE: do not forget to send an empty chunk at the end of the response,
NOTE: do not forget to send empty chunk at the end of the response,
to tell the client that everything was sent. Example:
```
......
......@@ -7,7 +7,7 @@ signature: |
const char *extra_headers);
---
Sends a response status line.
Send response status line.
If `extra_headers` is not NULL, then `extra_headers` are also sent
after the reponse line. `extra_headers` must NOT end end with new line.
Example:
......
......@@ -7,9 +7,9 @@ signature: |
const void *data, size_t data_len);
---
Send WebSocket frame to the remote end.
Send websocket frame to the remote end.
`op_and_flags` specifies the frame's type. It's one of:
`op_and_flags` specifies frame's type, one of:
- WEBSOCKET_OP_CONTINUE
- WEBSOCKET_OP_TEXT
......
......@@ -7,7 +7,7 @@ signature: |
const struct mg_str *strings, int num_strings);
---
Sends multiple WebSocket frames.
Send multiple websocket frames.
Like `mg_send_websocket_frame()`, but composes a frame from multiple buffers.
......@@ -7,14 +7,14 @@ signature: |
const char *extra_headers);
---
Sends WebSocket handshake to the server.
Send websocket handshake to the server.
`nc` must be a valid connection, connected to a server. `uri` is an URI
to fetch, `extra_headers` are extra HTTP headers to send or `NULL`.
to fetch, extra_headers` is extra HTTP headers to send or `NULL`.
This function is intended to be used by the WebSocket client.
This function is intended to be used by websocket client.
Note that the host header is mandatory in HTTP/1.1 and must be
Note that the Host header is mandatory in HTTP/1.1 and must be
included in `extra_headers`. `mg_send_websocket_handshake2` offers
a better API for that.
......
......@@ -8,12 +8,12 @@ signature: |
const char *extra_headers);
---
Send WebSocket handshake to the server.
Send websocket handshake to the server.
`nc` must be a valid connection, connected to a server. `uri` is an URI
to fetch, `host` goes into the `Host` header, `protocol` goes into the
`Sec-WebSocket-Proto` header (NULL to omit), `extra_headers` is an extra HTTP
header to send or `NULL`.
`Sec-WebSocket-Proto` header (NULL to omit), extra_headers` is extra HTTP
headers to send or `NULL`.
This function is intended to be used by the WebSocket client.
This function is intended to be used by websocket client.
......@@ -7,7 +7,7 @@ signature: |
struct mg_serve_http_opts opts);
---
Serves given HTTP request according to the `options`.
Serve given HTTP request according to the `options`.
Example code snippet:
......
......@@ -6,42 +6,43 @@ signature: |
void mg_set_protocol_http_websocket(struct mg_connection *nc);
---
Attach a built-in HTTP event handler to a given connection.
The user-defined event handler will receive the following extra events:
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_message` through the handler's `void *ev_data` pointer.
- MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has been received.
This event is sent before the body is parsed. After this the user
- 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. The parsed HTTP reply is passed as
- MG_EV_HTTP_REPLY: HTTP reply has arrived. Parsed HTTP reply is passed as
`struct http_message` through the handler's `void *ev_data` pointer.
- MG_EV_HTTP_CHUNK: HTTP chunked-encoding chunk has arrived.
The parsed HTTP reply is passed as `struct http_message` through the
Parsed HTTP reply is passed as `struct http_message` through the
handler's `void *ev_data` pointer. `http_message::body` would contain
incomplete, reassembled HTTP body.
It will grow with every new chunk arrived and could
potentially consume a lot of memory. An event handler may process
the body as chunks are coming in, and signal Mongoose to delete processed
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 setting `MG_F_DELETE_CHUNK` in `mg_connection::flags`. When
the last zero chunk is received,
Mongoose sends an `MG_EV_HTTP_REPLY` event with
the full reassembled body (if handler did not signal to delete chunks) or
with the empty body (if handler did signal to delete chunks).
- MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received WebSocket handshake
Mongoose sends `MG_EV_HTTP_REPLY` event 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_data` contains parsed HTTP request.
- MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed WebSocket handshake.
- MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed Websocket handshake.
`ev_data` is `NULL`.
- MG_EV_WEBSOCKET_FRAME: new WebSocket frame has arrived. `ev_data` is
- MG_EV_WEBSOCKET_FRAME: new websocket frame has arrived. `ev_data` is
`struct 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 has arrived.
No additional headers are available, only data and data size.
- MG_EV_HTTP_PART_END: final boundary received. Marks the end of the multipart 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,
......
......@@ -7,12 +7,12 @@ signature: |
int is_form_url_encoded);
---
Decodes URL-encoded string.
Decode URL-encoded string.
Source string is specified by (`src`, `src_len`), and destination is
(`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then
`+` character is decoded as a blank space character. This function
guarantees to `\0`-terminate the destination. If destination is too small,
then the source string is partially decoded and `-1` is returned. Otherwise,
then source string is partially decoded and `-1` is returned. Otherwise,
a length of decoded string is returned, not counting final `\0`.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment