2022-04-13 03:55 AM
Hi,
I'm working with the B-U585I-IOT02A board and I'm trying to extend the IOT_HTTP_WebServer example for my own demo. I'm using STM32CubeIDE Version: 1.9.0 and I created the IOT_HTTP_WebServer project via the "Example Selector" in the "STM32 Project" wizard. I think I found a bug in the IOT_HTTP_WebServer source code. If there's a better place to report a bug please let me know.
I became aware of the problem when I tried to add a new content type with its own set of HTTP headers. I extended the source code to produce specific HTTP headers according to the existing schema in IOT_HTTP_WebServer/Demonstration/User/WebServer/App/http/webserver_http_response.c in function http_send_headers_response(), but the headers would not appear when I looked at the HTTP response in the Chrome developer tools.
The problem can also be seen with the unmodified source code, for example by looking for the HTTP response headers with the Chrome developer tools for the CSS files sent by the IOT_HTTP_WebServer application, which are not received.
The bug is that two parameters are passed in the wrong order from http_send_response() to http_send_headers_response():
static WebServer_StatusTypeDef http_send_response(uint32_t headers_id,
uint32_t socket,
char *headers_buff,
const char *body_buff,
uint32_t data_size)
{
/* Send HTTP header response */
if (http_send_headers_response(headers_id, socket, headers_buff, data_size) != WEBSERVER_OK)
{
return HTTP_ERROR;
}
/* Send HTTP body response */
if (http_send(socket, (const char *)body_buff, data_size) != WEBSERVER_OK)
{
return HTTP_ERROR;
}
return WEBSERVER_OK;
}
/**
* @brief HTTP send headers responses data via socket
* @param socket : connection socket
* @param headers_id : specifies the header ID
* @param headers_buff : pointer to headers buffer
* @param data_size : size of body web resources
* @retval Web Server status
*/
static WebServer_StatusTypeDef http_send_headers_response(uint32_t socket,
uint32_t headers_id,
char *headers_buff,
uint32_t data_size)
{
...
}
http_send_response() calls http_send_headers_response(headers_id, socket, ...), while the signature of http_send_headers_response is http_send_headers_response(uint32_t socket, uint32_t headers_id, char *headers_buff, uint32_t data_size), so it expects the socket as the first parameter and the headers_id as the second parameter.
When I change the call to http_send_headers_response() in http_send_response to
http_send_headers_response(socket, headers_id, headers_buff, data_size)
then the HTTP headers are sent as expected.
Best regards
Stephan
2022-04-14 11:20 AM
I now found out that there's a GitHub repository for the STM32CubeU5 MCU Firmware Package. I submitted the following GitHub issue for the problem:
2022-04-19 08:55 AM
Hello @Stephan Mühlstrasser ,
First let me welcome you to the STM32 Community 🙂 and thank you for having reported this issue.
This limitation is confirmed and I submitted an internal ticket number 126626 (This is an internal tracking number and is not accessible or usable by customers).
Our team is working to fix this issue in the next STM32CubeU5 release.
Thank you for your patience while we work on this, and thank you once again for your contribution.
Thanks
Imen