mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
docs: update application examples for esp_http_server.rst, esp_https_server.rst, and mbedtls.rst
This commit is contained in:
@@ -84,11 +84,11 @@ The bundle is kept updated by periodic sync with the Mozilla's NSS root certific
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
Simple HTTPS example that uses ESP-TLS to establish a secure socket connection using the certificate bundle with two custom certificates added for verification: :example:`protocols/https_x509_bundle`.
|
||||
- :example:`protocols/https_x509_bundle` demonstrates how to use ESP-TLS to establish a secure socket connection using the certificate bundle with two custom certificates added for verification.
|
||||
|
||||
HTTPS example that uses ESP-TLS and the default bundle: :example:`protocols/https_request`.
|
||||
- :example:`protocols/https_request` demonstrates an HTTPS example that uses ESP-TLS and the default bundle.
|
||||
|
||||
HTTPS example that uses mbedTLS and the default bundle: :example:`protocols/https_mbedtls`.
|
||||
- :example:`protocols/https_mbedtls` demonstrates an HTTPS example that uses Mbed TLS and the default bundle.
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
@@ -13,10 +13,10 @@ Overview
|
||||
* :cpp:func:`esp_http_client_cleanup`: Closes the connection (if any) and frees up all the memory allocated to the HTTP client instance. This must be the last function to be called after the completion of operations.
|
||||
|
||||
|
||||
Application Example
|
||||
-------------------
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
Simple example that uses ESP HTTP Client to make HTTP/S requests can be found at :example:`protocols/esp_http_client`.
|
||||
- :example:`protocols/esp_http_client` demonstrates how to use the ESP HTTP Client to make HTTP/S requests.
|
||||
|
||||
|
||||
Basic HTTP Request
|
||||
|
@@ -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
|
||||
-------------
|
||||
|
||||
|
@@ -63,6 +63,13 @@ Expected data type for different ESP HTTPS server events in event loop:
|
||||
- HTTPS_SERVER_EVENT_DISCONNECTED : ``NULL``
|
||||
- HTTPS_SERVER_EVENT_STOP : ``NULL``
|
||||
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
- :example:`protocols/https_server/simple` demonstrates how to create an HTTPS server that returns a simple HTML page when visited.
|
||||
|
||||
- :example:`protocols/https_server/wss_server` demonstrates how to create an SSL server with a simple WebSocket request handler that supports handling multiple clients, PING-PONG mechanism, and sending asynchronous messages to all clients.
|
||||
|
||||
API Reference
|
||||
-------------
|
||||
|
||||
|
@@ -103,7 +103,7 @@ You may set security for transport in ESP local control using following options:
|
||||
Creating a Property
|
||||
-------------------
|
||||
|
||||
Now that we know how to start the **esp_local_ctrl** service, let's add a property to it. Each property must have a unique ```name``` (string), a ``type`` (e.g., enum), ``flags``` (bit fields) and ``size```.
|
||||
Now that we know how to start the **esp_local_ctrl** service, let's add a property to it. Each property must have a unique ``name`` (string), a ``type`` (e.g., enum), ``flags`` (bit fields) and ``size``.
|
||||
|
||||
The ``size`` is to be kept 0, if we want our property value to be of variable length (e.g., if it is a string or bytestream). For data types with fixed-length property value, like int, float, etc., setting the ``size`` field to the right value helps **esp_local_ctrl** to perform internal checks on arguments received with write requests.
|
||||
|
||||
@@ -178,7 +178,7 @@ Here is an example of ``set_prop_values()`` handler. Notice how we restrict from
|
||||
}
|
||||
|
||||
|
||||
For complete example see :example:`protocols/esp_local_ctrl`.
|
||||
For complete example see :example:`protocols/esp_local_ctrl`. The example demonstrates how to set up a secure ``esp_local_ctrl`` service over HTTPS transport for controlling devices on a local network.
|
||||
|
||||
Client Side Implementation
|
||||
--------------------------
|
||||
|
@@ -45,7 +45,7 @@ Examples in ESP-IDF use :doc:`/api-reference/protocols/esp_tls` which provides a
|
||||
|
||||
Refer to the examples :example:`protocols/https_server/simple` (Simple HTTPS server) and :example:`protocols/https_request` (Make HTTPS requests) for more information.
|
||||
|
||||
If the Mbed TLS API is to be used directly, refer to the example :example:`protocols/https_mbedtls`.
|
||||
If you plan to use the Mbed TLS API directly, refer to the example :example:`protocols/https_mbedtls`. This example demonstrates how to establish an HTTPS connection using Mbed TLS by setting up a secure socket with a certificate bundle for verification.
|
||||
|
||||
|
||||
Alternatives
|
||||
|
Reference in New Issue
Block a user