Commit Graph

114 Commits

Author SHA1 Message Date
Ashish Sharma
acf89924c8 feat(esp_http): migrate esp_http to PSA API 2025-10-26 10:13:14 +08:00
hrushikesh.bhosale
cfc056018c 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-16 15:02:05 +05:30
Joonline
9e7074dd35 fix(http_server): Corrected initialization value for lru_counter at http session creation
Closes https://github.com/espressif/esp-idf/pull/17470
2025-09-12 15:31:27 +08:00
Mahavir Jain
b789445a67 Merge branch 'contrib/github_pr_17501' into 'master'
fix(esp_http_server): fix memory leak in httpd_req_async_handler_begin (GitHub PR)

Closes IDFGH-16361

See merge request espressif/esp-idf!41748
2025-09-10 13:15:36 +05:30
Salvatore Mesoraca
fd33d02563 fix(esp_http_server): fix memory leak in httpd_req_async_handler_begin
Free scratch memory when response headers allocation fails
2025-08-29 02:11:13 +02:00
Alexey Lapshin
28ced4efad fix(config): actualize newlib Kconfig options 2025-08-28 12:25:09 +08:00
Aditya Patwardhan
a783974d00 Merge branch 'feat/support_authentication_feature_for_ws' into 'master'
Added pre handshake callback for websocket

Closes IDF-13605

See merge request espressif/esp-idf!40706
2025-07-31 15:04:07 +05:30
hrushikesh.bhosale
a40ceffb19 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-07-31 11:06:18 +05:30
Ashish Sharma
6b02906822 fix(security): improve memory allocation handling in multiple components 2025-07-28 10:05:50 +08:00
Mahavir Jain
464d03f999 Merge branch 'contrib/github_pr_15767' into 'master'
fix(esp_http_server): WebSocket frame parsing errors (GitHub PR)

Closes IDFGH-15086 and IDFGH-14461

See merge request espressif/esp-idf!40076
2025-07-16 13:58:37 +05:30
Vincent Hamp
ab07377b11 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-15 11:26:35 +05:30
hrushikesh.bhosale
9f6ab55a5b feat(http_server): Added API to get scratch buffer data
1. Added the API in esp_http_server to get the raw headers data
from the scratch buffer.
2. This data will be unparsed.

Closes https://github.com/espressif/esp-idf/issues/15857
2025-07-09 18:36:52 +05:30
iranl
42704821d2 fix(esp_http_server): Fix regression in httpd_cookie_key_value
Fix regression in httpd_cookie_key_value introduced by commit 4a47cf8
2025-07-02 08:39:20 +02:00
hrushikesh.bhosale
542d07d34a 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-13 11:27:02 +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
harshal.patil
e738ec5ccd fix(esp-tls): Fix build failure when CONFIG_MBEDTLS_SHA1_C is disabled 2025-04-21 13:38:29 +05:30
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
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
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
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
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
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
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
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
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
Harshit Malpani
7c68b67295 esp_http_server: Update to support build for Linux 2023-03-31 16:42:05 +05:30
David Cermak
5f6cb31105 lwip: Support IPv6 only mode 2023-02-27 08:53:34 +01: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
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
Harshit Malpani
89a56392e3 esp_http_server: fix wrong context pointer in httpd_req_cleanup function
Added example which fails without the fix

Closes https://github.com/espressif/esp-idf/issues/10265
2022-12-16 14:40:37 +05:30
Nathan Phillips
2d047f5439 Fix type of cast 2022-12-08 10:51:16 +00:00
Mahavir Jain
79216c657e esp_http_server: modify error print for clarifying internal socket usage
Closes https://github.com/espressif/esp-idf/issues/10108
Closes IDFGH-8663
2022-11-15 20:46:35 +05:30
yuanjianmin
e05d61d075 esp_http_server: Add support to enable TCP keepalive config
Closes https://github.com/espressif/esp-idf/issues/9848
2022-10-31 14:37:05 +08:00