docs: update application examples for esp_http_server.rst, esp_https_server.rst, and mbedtls.rst

This commit is contained in:
Linda
2024-09-20 15:08:41 +08:00
parent 1ac6043bce
commit ef9cfa5998
12 changed files with 93 additions and 25 deletions
@@ -12,8 +12,8 @@ The HTTP Server component provides an ability for running a lightweight web serv
* :cpp:func:`httpd_stop`: This stops the server with the provided handle and frees up any associated memory/resources. This is a blocking function that first signals a halt to the server task and then waits for the task to terminate. While stopping, the task closes all open connections, removes registered URI handlers and resets all session context data to empty.
* :cpp:func:`httpd_register_uri_handler`: A URI handler is registered by passing object of type ``httpd_uri_t`` structure which has members including ``uri`` name, ``method`` type (eg. ``HTTPD_GET/HTTPD_POST/HTTPD_PUT`` etc.), function pointer of type ``esp_err_t *handler (httpd_req_t *req)`` and ``user_ctx`` pointer to user context data.
Application Example
-------------------
Application Examples
--------------------
.. code-block:: c
@@ -106,7 +106,12 @@ Application Example
Simple HTTP Server Example
^^^^^^^^^^^^^^^^^^^^^^^^^^
Check HTTP server example under :example:`protocols/http_server/simple` where handling of arbitrary content lengths, reading request headers and URL query parameters, and setting response headers is demonstrated.
:example:`protocols/http_server/simple` demonstrates how to handle arbitrary content lengths, read request headers and URL query parameters, and set response headers.
Advanced Testing Example
^^^^^^^^^^^^^^^^^^^^^^^^
:example:`protocols/http_server/advanced_tests` demonstrates how to use the HTTP server for advanced testing.
Persistent Connections
@@ -146,13 +151,15 @@ Persistent Connections Example
}
Check the example under :example:`protocols/http_server/persistent_sockets`.
Check the example under :example:`protocols/http_server/persistent_sockets`. This example demonstrates how to set up and use an HTTP server with persistent sockets, allowing for independent sessions or contexts per client.
Websocket Server
WebSocket Server
----------------
The HTTP server component provides websocket support. The websocket feature can be enabled in menuconfig using the :ref:`CONFIG_HTTPD_WS_SUPPORT` option. Please refer to the :example:`protocols/http_server/ws_echo_server` example which demonstrates usage of the websocket feature.
The HTTP server component provides WebSocket support. The WebSocket feature can be enabled in menuconfig using the :ref:`CONFIG_HTTPD_WS_SUPPORT` option.
:example:`protocols/http_server/ws_echo_server` demonstrates how to create a WebSocket echo server using the HTTP server, which starts on a local network and requires a WebSocket client for interaction, echoing back received WebSocket frames.
Event Handling
@@ -174,6 +181,26 @@ Expected data type for different ESP HTTP server events in event loop:
- HTTP_SERVER_EVENT_DISCONNECTED : ``int``
- HTTP_SERVER_EVENT_STOP : ``NULL``
File Serving
------------
:example:`protocols/http_server/file_serving` demonstrates how to create a simple HTTP file server, with both upload and download capabilities.
Captive Portal
--------------
:example:`protocols/http_server/captive_portal` demonstrates two methods of creating a captive portal, which directs users to an authentication page before browsing, using either DNS queries and HTTP requests redirection or a modern method involving a field in the DHCP offer.
Asynchronous Handlers
---------------------
:example:`protocols/http_server/async_handlers` demonstrates how to handle multiple long-running simultaneous requests within the HTTP server, using different URIs for asynchronous requests, quick requests, and the index page.
RESTful API
-----------
:example:`protocols/http_server/restful_server` demonstrates how to implement a RESTful API server and HTTP server, with a frontend browser UI, and designs several APIs to fetch resources, using mDNS to parse the domain name, and deploying the webpage to host PC via semihost technology or to SPI flash or SD Card.
API Reference
-------------