This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 4b5bd23957a netlib: Supplement the netlib_check_httpconnectivity 
documentation
4b5bd23957a is described below

commit 4b5bd23957af614096f70d4f1b787519ea9d8008
Author: zhangshuai39 <[email protected]>
AuthorDate: Fri Jan 9 15:15:51 2026 +0800

    netlib: Supplement the netlib_check_httpconnectivity documentation
    
    A brief introduction to the interface functions, parameters, and return 
values.
    
    Signed-off-by: zhangshuai39 <[email protected]>
---
 .../applications/netutils/netlib/index.rst         | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/Documentation/applications/netutils/netlib/index.rst 
b/Documentation/applications/netutils/netlib/index.rst
index 3e1b7a6f43e..e5224d08109 100644
--- a/Documentation/applications/netutils/netlib/index.rst
+++ b/Documentation/applications/netutils/netlib/index.rst
@@ -344,6 +344,7 @@ Network Connectivity
 
   - :c:func:`netlib_check_ipconnectivity`
   - :c:func:`netlib_check_ifconnectivity`
+  - :c:func:`netlib_check_httpconnectivity`
 
 .. c:function:: int netlib_check_ipconnectivity(FAR const char *ip, int 
timeout, int retry)
 
@@ -388,6 +389,39 @@ Network Connectivity
   retrieve the gateway address and then uses 
:c:func:`netlib_check_ipconnectivity`
   to perform the actual ping test.
 
+.. c:function:: int netlib_check_httpconnectivity(FAR const char *host, FAR 
const char *getmsg, int port, int expect_code)
+
+  Check HTTP service connectivity by sending an HTTP GET request and verifying
+  the response status code. This function establishes a TCP connection to the
+  specified host and port, sends an HTTP/1.1 GET request for the specified 
path,
+  and validates that the server returns the expected HTTP status code.
+
+  :param host: Remote hostname or IP address (e.g., ``"www.example.com"`` or
+               ``"192.168.1.1"``). The function supports DNS resolution if
+               ``CONFIG_LIBC_NETDB`` is enabled, otherwise it expects a numeric
+               IPv4 address.
+  :param getmsg: URL path for the HTTP GET request (e.g., ``"index.html"`` or
+                 ``"api/health"``). An empty string (``""``) requests the root 
path
+                 (``"/"``). The function automatically prepends a forward slash
+                 to the path.
+  :param port: TCP port number of the HTTP server (typically 80 for HTTP, or
+               8080 for alternative HTTP services).
+  :param expect_code: Expected HTTP status code (e.g., ``200`` for success,
+                      ``404`` for not found). The function returns success only
+                      if the server returns this exact status code.
+
+  :return: 0 on success (HTTP status code matches expected value). A negative
+           value on failure, which may be a negative HTTP status code (e.g.,
+           ``-404``) if the server returned a different status code than 
expected,
+           or a negative error code (e.g., ``-EINVAL``, ``-ENETUNREACH``) if
+           connection, DNS resolution, or other errors occurred.
+
+  **Note:** This function is blocking and will wait for the HTTP request and
+  response to complete. The function only reads the first 256 bytes of the HTTP
+  response to extract the status code. It does not support HTTPS (TLS/SSL) and
+  only works with HTTP/1.1 servers. The function is useful for HTTP service
+  health checks, network diagnostics, and automated service monitoring.
+
 ARP Table Support
 ==================
 

Reply via email to