JorgeGzm opened a new pull request, #3651:
URL: https://github.com/apache/nuttx-apps/pull/3651

   ## Summary
   
   Add a small `curl`-like HTTP client command under `system/curl`, built on top
   of the `netutils/webclient` library. It brings the familiar `curl` option
   syntax to the NuttShell so HTTP servers can be exercised directly from the
   target.
   
   Supported options (a subset of the real curl, see 
https://curl.se/docs/manpage.html):
   
   - `-X <method>` : HTTP method (defaults to GET, or POST when a body is sent)
   - `-H <header>` : add a request header
   - `-d <data>` / `-d @file` : raw request body (inline or read from a file)
   - `-F name=@file` : multipart/form-data file upload
   - `-o <file>` : write the response body to a file
   - `-v` : verbose
   
   HTTP only (no HTTPS).
   
   ## Impact
   
   - New optional command guarded by `CONFIG_SYSTEM_CURL` (default `n`); no 
impact
     when disabled.
   - Depends on `CONFIG_NETUTILS_WEBCLIENT` / `CONFIG_NET_TCP`.
   - No change to any existing application.
   
   ## Testing
   
   - **Build Host:** Linux, `arm-none-eabi-gcc`
   - **Target:** `linum-stm32h753bi:curl` (companion NuttX PR adds this 
config), STM32H753BI over Ethernet + SD card
   - `nxstyle` clean on `system/curl/curl_main.c`.
   
   Runtime on hardware:
   
   ```
   nsh> ifconfig
   eth0    Link encap:Ethernet HWaddr 00:e0:de:ad:be:ef at RUNNING mtu 1486
           inet addr:192.168.15.3 DRaddr:192.168.15.1 Mask:255.255.255.0
   
   GET, saving the response to a file (-o):
   nsh> curl -o /mnt/dl.json http://httpbin.org/json
   curl: HTTP 200
   nsh> curl -o /mnt/img.png http://httpbin.org/image/png
   curl: HTTP 200
   nsh> ls -l /mnt/img.png
    -rw-rw-rw-        8090 /mnt/img.png
   
   POST JSON (-d selects POST, -H sets the type); httpbin echoes it back:
   nsh> curl -H Content-Type:application/json -d '{"temp":25.3,"hum":60}' 
http://httpbin.org/post
   {
     "data": "{\"temp\":25.3,\"hum\":60}",
     "json": { "hum": 60, "temp": 25.3 },
     "url": "http://httpbin.org/post";
   }
   curl: HTTP 200
   
   Custom method (-X):
   nsh> curl -X PUT -d '{"x":1}' http://httpbin.org/put
   curl: HTTP 200
   
   Multipart upload (-F name=@file) and download back (-o):
   nsh> curl -F file=@/mnt/nuttx_logo.png 
"http://192.168.15.12:8000/api/.../ota/upload?version=logo1";
   {"filename":"nuttx_logo.png","sha256":"ca278dcb...","size_bytes":40343}curl: 
HTTP 201
   nsh> curl -o /mnt/logo_back.png 
http://192.168.15.12:8000/api/.../ota/default/logo1/nuttx_logo.png
   curl: HTTP 200
   nsh> ls -l /mnt
    -rw-rw-rw-       40343 nuttx_logo.png
    -rw-rw-rw-       40343 logo_back.png
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to