Browse Source

Add missing functions to interface documentation

bel2125 8 years ago
parent
commit
c00041092c

+ 4 - 0
docs/APIReference.md

@@ -68,6 +68,9 @@ The content of both structures is not defined in the interface - they are only u
 
 * [`mg_get_context( conn );`](api/mg_get_context.md)
 
+* [`mg_send_http_error( conn, status_code, fmt, ... );`](api/mg_send_http_error.md)
+* [`mg_send_digest_access_authentication_request( conn, realm );`](api/mg_send_digest_access_authentication_request.md)
+
 
 ## Client API Functions
 
@@ -98,6 +101,7 @@ The content of both structures is not defined in the interface - they are only u
 * [`mg_modify_passwords_file( passwords_file_name, domain, user, password );`](api/mg_modify_passwords_file.md)
 * [`mg_printf( conn, fmt, ... );`](api/mg_printf.md)
 * [`mg_read( conn, buf, len );`](api/mg_read.md)
+* [`mg_send_chunk( conn, buf, len );`](api/mg_send_chunk.md)
 * [`mg_send_file( conn, path );`](api/mg_send_file.md)
 * [`mg_send_mime_file( conn, path, mime_type );`](api/mg_send_mime_file.md)
 * [`mg_send_mime_file2( conn, path, mime_type, additional_headers );`](api/mg_send_mime_file2.md)

+ 8 - 4
docs/api/mg_send_chunk.md

@@ -7,8 +7,8 @@
 | Parameter | Type | Description |
 | :--- | :--- | :--- |
 |**`conn`**|`struct mg_connection *`| A pointer to the connection to be used to send data |
-|**`chunk`**|`const void *`| A pointer to the data to be sent |
-|**`chunk_len`**|`size_t`| The number of bytes to be sent |
+|**`chunk`**|`const void *`| A pointer to the blob of information to be sent |
+|**`chunk_len`**|`size_t`| The amount of bytes to be sent |
 
 ### Return Value
 
@@ -18,10 +18,14 @@
 
 ### Description
 
-The function `mg_send_chunk()` can be used to send a block of data, if chunked transfer encoding is used. Only use this function after sending a complete HTTP request or response header with the "Transfer-Encoding: chunked" header field set.
-The function returns the amount of bytes sent in case of success, or **-1** in case of an error.
+The function `mg_send_chunk()` can be used to send a blob of arbitrary data over a connection. 
+Only use this function after sending a complete HTTP request or response header with "Transfer-Encoding: chunked" set. Otherwise: use `mg_write()`.
+The function returns a number **>0** if data was sent, the value **0** when the connection has been closed, and **-1** in case of an error.
 
 ### See Also
 
 * [`mg_write();`](mg_write.md)
 * [`mg_printf();`](mg_print.md)
+* [`mg_lock_connection();`](mg_lock_connection.md)
+* [`mg_unlock_connection();`](mg_unlock_connection.md)
+

+ 31 - 0
docs/api/mg_send_digest_access_authentication_request.md

@@ -0,0 +1,31 @@
+# Civetweb API Reference
+
+### `mg_send_digest_access_authentication_request( conn, realm );`
+
+### Parameters
+
+| Parameter | Type | Description |
+| :--- | :--- | :--- |
+|**`conn`**|`struct mg_connection *`| A pointer to the connection to be used to send data |
+|**`realm`**|`const char *`| The requested authentication realm or NULL |
+
+### Return Value
+
+| Type | Description |
+| :--- | :--- |
+|`int`| An integer indicating success or failure |
+
+### Description
+
+This function can be used to send a HTTP Digest Authentication request to the client.
+Browsers will react with repeating the request with user authentication data.
+If they do not yet know the user authentication for the requested realm, they will show
+a dialog to query username and password.
+The function returns a negative number on errors.
+
+### See Also
+
+* [`mg_send_http_error();`](mg_send_http_error.md)
+* [`mg_write();`](mg_write.md)
+* [`mg_printf();`](mg_print.md)
+

+ 13 - 7
docs/api/mg_send_http_error.md

@@ -6,21 +6,27 @@
 
 | Parameter | Type | Description |
 | :--- | :--- | :--- |
-|**`conn`**|`struct mg_connection *`|The connection over which the file must be sent|
-|**`status_code`**|`int`|The HTTP status code to return|
-|**`fmt`**|`const char *`|Format string specifying the remote command to execute|
-|**`...`**|*various*|Parameters used in the format string|
+|**`conn`**|`struct mg_connection *`|The connection over which the data must be sent|
+|**`status_code`**|`int`|The HTTP status code (see HTTP standard)|
+|**`fmt`**|`const char *`|Format string for an error message|
+|**`...`**|*various*|Parameters as specified in the format string|
 
 ### Return Value
 
-*none*
+| Type | Description |
+| :--- | :--- |
+
 
 ### Description
 
-The function `mg_send_http_error()` sends a HTTP reply with the given status code and the content specified by fmt. The textual status code is determined from the numerical status code internally.
+The function `mg_send_http_error()` can be used to send HTTP error messages from a server to a client.
+The `status_code` must be one of the predefined HTTP standard error codes (e.g., "404" for "Not Found").
+The status text (e.g., "Not Found") for standard error codes is known by this function.
+A body of the error message, to explain the error in more detail, can be specified using the `fmt` format specifier and additional arguments. The `fmt` format specifier works like for the `printf()` function in the standard C library.
+
 
 ### See Also
 
 * [`mg_printf();`](mg_printf.md)
 * [`mg_write();`](mg_write.md)
-* [`mg_send_file();`](mg_send_file.md)
+

+ 2 - 0
include/civetweb.h

@@ -774,6 +774,8 @@ CIVETWEB_API void mg_send_http_error(struct mg_connection *conn,
  *   conn: Current connection handle.
  *   realm: Authentication realm. If NULL is supplied, the sever domain
  *          set in the authentication_domain configuration is used.
+ * Return:
+ *   < 0   Error
  */
 CIVETWEB_API int
 mg_send_digest_access_authentication_request(struct mg_connection *conn,