Commit Graph

145 Commits

Author SHA1 Message Date
Peter Backeris 3d0e26170d 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:56:13 +08:00
Evgeny Torbin f7395255da test: format all test scripts 2026-03-11 07:34:34 +01:00
Mahavir Jain cb0a0561c6 Merge branch 'fix/fix_possible_ws_server_deadlock_v5.4' into 'release/v5.4'
fix: fix potential ws server deadlock with blocking work queue (v5.4)

See merge request espressif/esp-idf!45366
2026-01-27 16:39:21 +05:30
Ashish Sharma 47045dad5f fix: stop reading ws data when peer closes the connection
Closes https://github.com/espressif/esp-idf/issues/17822
2026-01-22 18:16:49 +08:00
Ashish Sharma b8c3815800 fix: fixes potential ws server deadlock with blocking work queue
Closes https://github.com/espressif/esp-idf/issues/17591
2026-01-22 18:13:21 +08:00
hrushikesh.bhosale eae77c8767 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:11:06 +05:30
hrushikesh.bhosale 3a7380f5bc 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-06 11:43:22 +05:30
Vincent Hamp b7ab27341e 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:15:08 +05:30
Mahavir Jain 7ac6f01b94 Merge branch 'feat/httpd_register_uri_handler_strdup_failure_case_check_v5.4' into 'release/v5.4'
Handling httdp_register_uri_handler() strdup function failure case check (v5.4)

See merge request espressif/esp-idf!39512
2025-06-26 13:38:51 +05:30
wanckl ea03622621 ci(esp32c61): remove c61 support from readme on 5.4 2025-06-17 15:09:40 +08:00
hrushikesh.bhosale 923ac4da5a 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:50:14 +05:30
Jiang Jiang Jian 45d95b1bd8 Merge branch 'fix/fix_esp32p4_retention_cost_v5.4' into 'release/v5.4'
fix(esp_hw_support): optimize retention cost and update sleep time compensation (v5.4)

See merge request espressif/esp-idf!38744
2025-05-06 14:18:49 +08:00
harshal.patil 37dba24869 fix(esp-tls): Fix build failure when CONFIG_MBEDTLS_SHA1_C is disabled 2025-04-29 10:53:06 +05:30
wuzhenghui 33aca83c63 change(ci): remove esp32c5 from readme since esp32c5 skipped CI build 2025-04-25 17:13:27 +08:00
hrushikesh.bhosale f96a118ebf 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-10 11:09:31 +05:30
nilesh.kale 4026e64c32 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-16 14:10:30 +05:30
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
laokaiyao 65b1fd33d3 ci(esp32c5mp): disable the unsupported tests 2024-04-07 12:13:29 +08:00
Mooneer Salem f799e99909 fix: Allocate HTTP header space for async httpd_req_t objects
This resolves bug #13430 by allocating a new copy of resp_hdrs
when calling httpd_req_async_handler_begin(), thus preventing
invalid access to memory from async tasks.
2024-03-27 00:50:29 -07:00
Jakob Hasse 4d629be602 refactor(linux): Unified libbsd handling
* Users can now use libbsd string.h and sys/cdefs.h functionality
  (e.g., strlcpy, containerof) on Linux by just including
  string.h or sys/cdefs.h. In other words, the includes are the same
  on the Linux target as well as on chips targets (ESP32, etc.).
* libbsd linking is done by the linux component (belongs to common
  components) now instead of handling it separately in each component
2024-03-08 12:26:54 +08:00
Marius Vikhammer 1f7c666701 ci(test_apps): limit dependencies for misc test_apps
Only pull in direct dependencies for the test apps, reducing build time
as well making it possible for CI to determine if the test should run or not
when dependencies are changed.
2024-02-18 16:01:58 +08:00
Harshit Malpani 1d81af367d feat: support HTTP_ANY method in esp_http_server
Closes https://github.com/espressif/esp-idf/issues/12794
2024-01-15 14:32:06 +05:30
Harshit Malpani ae71e1ddb9 fix(esp_http_server): Add support for custom HTTP status codes
Closes https://github.com/espressif/esp-idf/issues/12399
2023-12-20 16:59:38 +05:30
Ivan Grokhotkov 49f289f893 fix(esp_http_server): fix build for IDF_TARGET=linux on macOS 2023-12-19 13:28:59 +01:00
Alon Bar-Lev af79fe0495 change(components/esp_http_server): add task_caps configuration
The HTTP server is not a critical component, it would be nice if we can
control the task caps by using configuration.

Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
2023-12-13 12:26:59 +05:30
Ivan Grokhotkov 88fa79fcc7 feat(unity): upgrade to 2.6.0-RC1 2023-11-28 20:22:02 +01:00
Harshit Malpani 692e1a9e61 feat: ECDSA peripheral while performing http connection with mutual auth 2023-09-08 12:22:41 +05:30
Armando 7dbd3f6909 feat(ci): Enable p4 example, test_apps and unit tests CI build 2023-08-24 12:51:19 +08:00
Chip Weinberger 3824eba04d feat(httpd): add support for asynchronous request handling
This commit adds support for handling multiple requests simultaneously by introducing two new functions: `httpd_req_async_handler_begin()` and `httpd_req_async_handler_complete()`. These functions allow creating an asynchronous copy of a request that can be used on a separate thread and marking the asynchronous request as completed, respectively.

Additionally, a new flag `for_async_req` has been added to the `httpd_sess_t` struct to indicate if a socket is being used for an asynchronous request and should not be purged from the LRU cache.

An example have been added to demonstrate the usage of these new functions.

Closes https://github.com/espressif/esp-idf/issues/10594

Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
2023-05-19 10:05:42 +05:30
David Cermak b2af4d9689 lwip/linux: Add lwip support for networking component under linux
linux/lwip: Wrap some IO posix functions
* to workaourd the FreeRTOS EINTR issue (when building without lwip)
* to correctly choose the sub-system based on fd (when building with
lwip) -- passing control to either linux/system or to lwip
This commit also addapts tapio-if to provide DHCP client by default and
configurable settings for static IP
2023-05-05 05:03:39 +00:00
Harshit Malpani 7c68b67295 esp_http_server: Update to support build for Linux 2023-03-31 16:42:05 +05:30
Marius Vikhammer 0be8e03907 ci: update test apps to use run_all_single_board_cases 2023-03-10 14:27:09 +08:00
David Cermak 5f6cb31105 lwip: Support IPv6 only mode 2023-02-27 08:53:34 +01:00
Omar Chebib 5e5343d429 TWDT: Use the new TWDT Kconfig options in the examples and tests 2023-02-17 11:22:25 +08:00
Harshit Malpani e1e46e5dae esp_http_server: fix return values for httpd_socket_send() and httpd_socket_recv() APIs
Closes https://github.com/espressif/esp-idf/issues/10658
2023-01-31 11:29:49 +05:30
Cao Sen Miao 94120b82c2 esp32h2: add build test 2023-01-17 10:29:04 +08:00
Mahavir Jain 035c2e5799 esp_http(s)_server: remove "Wno-format" cflag and fix formatting errors 2022-12-21 14:14:04 +05:30
Harshit Malpani 0885d8542d esp_http_server: Added support for esp_events 2022-12-19 17:33:37 +05:30