Commit Graph

166 Commits

Author SHA1 Message Date
Mahavir Jain d2bcaba7e1 Merge branch 'fix/fix_ws_server_subprotocols_null_dereference_v5.5' into 'release/v5.5'
fix: fixes websocket server possible null dereference (v5.5)

See merge request espressif/esp-idf!46918
2026-03-30 10:31:32 +05:30
Mahavir Jain 4322004453 Merge branch 'contrib/github_pr_18310_v5.5' into 'release/v5.5'
fix(esp_http_server): Dispatch PONG frames to WebSocket handler (GitHub PR) (v5.5)

See merge request espressif/esp-idf!46656
2026-03-30 10:24:02 +05:30
Ashish Sharma 08c8c17436 fix: fixes memory leak with subprotocols 2026-03-23 18:42:48 +08:00
Ashish Sharma 00a2f7fbbb fix: fixes websocket server possible null dereference 2026-03-23 18:42:45 +08:00
Peter Backeris 0d7ab3a2a7 fix(esp_http_server): Dispatch PONG frames to WebSocket handler
PONG frames (opcode 0xA) were never dispatched to the user's WebSocket
handler despite an existing comment stating they should be. The dispatch
condition `ra->ws_type < HTTPD_WS_TYPE_CLOSE` excluded PONG (0xA)
since CLOSE is 0x8.

This caused a critical secondary bug: when the server sends PING frames
and the client responds with PONG, httpd_ws_recv_frame() is never
called for the PONG, leaving the remaining frame bytes (second_byte
plus 4-byte mask_key) unconsumed in the TCP buffer. On the next
WebSocket read, these orphaned bytes are misinterpreted as a new frame
header, causing either "WS frame is not properly masked" errors or
EAGAIN timeouts with garbage length values, effectively destroying
the connection.

Add `ra->ws_type == HTTPD_WS_TYPE_PONG` to the dispatch condition so
PONG frames reach the user handler, which calls httpd_ws_recv_frame()
to properly consume the frame bytes from the socket.

Closes https://github.com/espressif/esp-idf/issues/18227
2026-03-16 16:55:54 +08:00
Ashish Sharma 6f392e6fd6 feat(http_server): improve websocket server handling
1. Adds post handshake callback
2. Removes requirement to handle HTTP_GET message in websocket handler

Closes https://github.com/espressif/esp-idf/issues/18215
2026-03-16 13:57:59 +08:00
Jiang Jiang Jian ffc215cfe0 Merge branch 'fix/stop_receive_on_ws_socket_close_v5.5' into 'release/v5.5'
fix: stop reading ws data when peer closes the connection (v5.5)

See merge request espressif/esp-idf!45368
2026-01-23 10:29:18 +08:00
Ashish Sharma 7ef71e9770 fix: stop reading ws data when peer closes the connection
Closes https://github.com/espressif/esp-idf/issues/17822
2026-01-22 18:16:37 +08:00
Ashish Sharma 4c0c9d2d6a fix: fixes potential ws server deadlock with blocking work queue
Closes https://github.com/espressif/esp-idf/issues/17591
2026-01-22 18:12:03 +08:00
Joonline ded0c3fec6 fix(http_server): Corrected initialization value for lru_counter at http session creation
Closes https://github.com/espressif/esp-idf/pull/17470
2025-09-22 09:40:47 +08:00
hrushikesh.bhosale d564f728ed fix(esp_http_server): Fix async requests on same socket blocking issue
1. In async requests, if the two or more requests are made on same
socket then it used to block the second request.
2. The main thread is used to block on select call. And there done
no FD_SET for particular fd.

Closes https://github.com/espressif/esp-idf/issues/16998
2025-09-18 16:09:51 +05:30
hrushikesh.bhosale 415a05a6a5 feat(esp_http_server): Added pre handshake callback for websocket
1. If the user wants authenticate the request, then user needs to do
this before upgrading the protocol to websocket.
2. To achieve this, added pre_handshake_callack, which will execute
before handshake, i.e. before switching protocol.
2025-08-04 20:58:54 +05:30
Jiang Jiang Jian 6dcd234495 Merge branch 'contrib/github_pr_16202_v5.5' into 'release/v5.5'
fix(esp_http_server): Fix regression in httpd_cookie_key_value introduced by commit 4a47cf8 (GitHub PR) (v5.5)

See merge request espressif/esp-idf!40455
2025-07-22 17:32:27 +08:00
Vincent Hamp 4ab1ec36ea fix(esp_http_server): WebSocket frame parsing errors
Fixes the Websocket frame pasring error, by making sure
that two bytes are read compulsary for length bytes 126.

Closes https://github.com/espressif/esp-idf/pull/15767
Closes https://github.com/espressif/esp-idf/issues/15235
2025-07-16 14:14:54 +05:30
iranl 665338d526 fix(esp_http_server): Fix regression in httpd_cookie_key_value
Fix regression in httpd_cookie_key_value introduced by commit 4a47cf8
2025-07-08 16:15:28 +05:30
hrushikesh.bhosale b9c586ebd1 feat(http_server): httpd register handler strdup failure case check
In httpd_register_uri_handler api, for the strdup function failure case was not
checked and not returned any error by freeing previously allocated memory, if the memory
allocation for strdup function did not gets successful.

Closes https://github.com/espressif/esp-idf/issues/15878
2025-05-29 11:49:57 +05:30
hrushikesh.bhosale b6d4fa2c2e fix(async_handler): Async handler example scratch buffer fix
1. In httpd_req_async_handler_begin, the httpd_req_aux is locally malloced
and data is  done memcpy to local httpd_req_aux from request'ss httpd_req_aux for
async request use-case, this causes scartch pointer from these two structs
pointing to same memory address.
2. In current workflow, the request's sratch buffer is freed in httpd_parse.c
httpd_req_cleanup api. Therefore if the user try to fetch the data (like headers)
from the scratch buffer, data will be not available.
3. Each request should have the deep copy of the scratch buffer. To retrive
the data later.

Closes https://github.com/espressif/esp-idf/issues/15587
2025-04-28 14:57:21 +08:00
Aditya Patwardhan bb9f73a786 Merge branch 'contrib/github_pr_15821' into 'master'
fix(esp_http_server): Fix incorrect spelling in the comments (GitHub PR)

Closes IDFGH-15144

See merge request espressif/esp-idf!38569
2025-04-23 20:42:03 +08:00
harshal.patil e738ec5ccd fix(esp-tls): Fix build failure when CONFIG_MBEDTLS_SHA1_C is disabled 2025-04-21 13:38:29 +05:30
WangLei1993 a2ce331ef9 fix(esp_http_server): Fix incorrect spelling in the comments 2025-04-20 15:57:03 +08:00
Mahavir Jain c263a3f9c5 Merge branch 'contrib/github_pr_15288' into 'master'
Improve httpd string value fetching efficiency (GitHub PR)

Closes IDFGH-14524

See merge request espressif/esp-idf!37301
2025-04-06 19:17:28 +08:00
hrushikesh.bhosale 4a47cf803c feat(esp_http_server/httpd_parse): Cosmetic changes in httpd_parse.c
Removed the unused variable buf_len
2025-04-04 16:45:11 +05:30
Chen Jichang c34b4eb882 feat(esp32h4): enable ESP32H4 ci build 2025-03-28 14:41:28 +08:00
Mahavir Jain 884c85536d Merge branch 'bugfix/http_ws_api_reference' into 'master'
fix(esp_http_server): enable doxygen build for websocket API reference

Closes IDFGH-14785

See merge request espressif/esp-idf!37529
2025-03-11 19:12:36 +08:00
Mahavir Jain 4b6c5f34cd fix(esp_http_server): enable doxygen build for websocket API reference
Closes https://github.com/espressif/esp-idf/issues/15523
2025-03-05 20:06:16 +05:30
igor.udot daf2d31008 test: format all test scripts 2025-03-05 12:08:48 +08:00
hrushikesh.bhosale 56de1f4ed1 fix(http_txrx): Resource leak in http_txrx
res_buf was not freed for the chunk response type in case of
first_chunk_sent true condition.

This commit ensures that resp_buf is freed and few cosmetic
changes are made
2025-02-24 15:45:58 +05:30
hrushikesh.bhosale 9846584def feat(esp_http_server): Modified the calculation of buf_len
Modified the calculation of buf_len, so that scratch buffer allocates
the memory according to requirement and not extra (except the last read chunk)
2025-02-13 17:15:07 +05:30
hrushikesh.bhosale 97b6043435 feat(esp_http_server): Dynamically allocate http server's scratch buffer
In this commit, esp_http_server's http_parser scratch is made dynamic.
User is asked to give limit size for header and URI, according to which
scratch buufer allocates memory upto limits
2025-02-11 09:41:26 +05:30
Gao Xu 1e8a48db74 Merge branch 'feat/h21_enable_ci_build_test' into 'master'
feat(esp32h21): enable ESP32H21 ci build

Closes IDF-11561

See merge request espressif/esp-idf!36197
2025-02-07 14:10:54 +08:00
gaoxu 5ef4f20778 feat(esp32h21): disable unsupported build test 2025-02-06 15:47:51 +08:00
hrushikesh.bhosale ef9259775e fix(http_server): Simple http server socket len fix
The socket address length is not typecasted properly while
passing to bind and sendto functions. Due to this
http_server/simple was not running with target linux on MacOS
used to give error -

I (132253266) port: Starting scheduler.
I (132253269) esp_netif_loopback: loopback initialization
I (132253269) example: Starting server on port: '8001'
E (132253270) httpd: httpd_server_init: error in creating ctrl socket (22)
I (132253270) example: Error starting server!

With this commit, simple http server runs with target linux
on MacOS for IPV4 configurations
2025-02-04 15:35:26 +05:30
Zhenyu Wu 16d9b94c56 refactor(esp_http_server): Improve httpd string value fetching efficiency
- Avoid using `strlcpy()` when source is not null-terminated;
- Avoid duplicate `strlen()` when `strlcpy()` is used.
2025-01-26 15:30:16 -05:00
Mahavir Jain 6502148fdc fix(examples): simple http_server example build for Linux target
Static task creation on Linux target had issues with insufficient stack
memory allocation. Type of `StackType_t` is `unsigned long` and hence
it must be considered during stack memory allocation.

Fix ensures proper working of simple HTTP server example.
2025-01-10 09:50:18 +05:30
hrushikesh.bhosale 84b8df8f3f feat(https_server): Added checks to verify if uri is empty
Added the checks if the URI is empty for the funtions httpd_req_get_url_query_len
and httpd_req_get_url_query_str in httpd_parser.c
2025-01-07 16:58:54 +08:00
nilesh.kale d5ccc60eb0 feat(esp_http_server): add support to handle HTTP 1.0 requests
This commit adds support to handle HTTP/1.0 requests alongside HTTP/1.1 for
legacy compliance purposes.
2024-12-11 15:32:32 +05:30
nick black 6b3ae2822d docs: fix all references to HTTPD_{GET,POST,PUT} 2024-11-04 16:13:07 +08:00
nilesh.kale d66442b74a fix(esp_http_server): updated condition to verify http version
Closes https://github.com/espressif/esp-idf/issues/14723
2024-10-15 17:56:13 +05:30
Alexey Lapshin a262e879d1 fix(esp_http_server): fix GCC 14 analyzer warnings 2024-09-08 13:53:52 +07:00
snake-4 8bade3bf2c fix(http_server): Don't require LWIP_NETIF_LOOPBACK for Linux target 2024-08-21 04:25:10 +02:00
Mahavir Jain 940578f9fe Merge branch 'contrib/github_pr_14196' into 'master'
fix(esp_http_server): prevent concurrent access to socket used in async http requests (GitHub PR)

Closes IDFGH-13263 and IDFGH-13053

See merge request espressif/esp-idf!32267
2024-07-26 14:09:25 +08:00
Friedolin Gröger 4a7f371056 fix(esp_http_server): prevent concurrent access to socket used in async http requests 2024-07-16 10:46:50 +02:00
wanlei 3cf069c7d8 feat(esp32c61): disable unsupported build test 2024-07-16 16:06:19 +08:00
Yogesh Mantri 586207207f change(esp_netif): Add Non-Fatal errtype to indicate lower layer medium failure
UDP application sends packet using esp_netif, underlying transport such
as Wi-Fi may drop the packet due to higher load. New error code
represent transient, non-fatal packet drop error. udp application may
use such errtype, for example to rate limit.
2024-06-11 09:20:49 +02:00
Harshit Malpani 61a3466941 fix: Fix spelling mistakes in esp_http_server.h 2024-05-29 18:30:00 +05:30
Maciej Małecki e40b1402e4 feat(http_server): add 413 Payload Too Large response
While not useful for the HTTP parser itself, this is very useful for
memory-limited consumers of the HTTP server API.

Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
2024-05-29 18:30:00 +05:30
Mahavir Jain a3dff04cf3 Merge branch 'bugfix/fix_resetting_redirect_counter' into 'master'
fix: reset redirect counter for using same handler

Closes IDFGH-12636 and IDFGH-12667

See merge request espressif/esp-idf!30395
2024-05-10 12:02:36 +08:00
Harshit Malpani 1ac2ebbeb9 fix: Add config option to set timeout for posting events
Event posting to the event loop should not hinder the working of
HTTP Client or HTTP Server. This commit add a config option to set
the timeout for posting the events to the loop.

Closes https://github.com/espressif/esp-idf/issues/13641
2024-05-08 11:41:05 +05:30
Harshit Malpani ef5e4ddee8 fix: Add warning to enable LWIP_NETIF_LOOPBACK to use control socket API
Closes https://github.com/espressif/esp-idf/issues/13659
2024-05-07 10:39:12 +05:30
Aditya Patwardhan d444ff58ec Merge branch 'contrib/github_pr_13462' into 'master'
fix: Allocate HTTP header space for async httpd_req_t objects (GitHub PR)

Closes IDFGH-12445

See merge request espressif/esp-idf!29868
2024-04-22 14:17:21 +08:00