Skip to content

Commit

Permalink
[#282] Add comments, defines, fix issues found by SonarCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSomeMan committed Feb 19, 2024
1 parent b1f2b41 commit a8c824a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/http_server_accept_and_handle_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@

#define FULLBUF_SIZE (4U * 1024U)

#define HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG (256U)
#define HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FOR_JSON_RESP (256U)
#define HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FROM_JSON_GENERATOR (4U * 1024U)

#define HTTP_SERVER_DELAY_BETWEEN_NETCONN_WRITE_MS (5)

#define HTTP_HEADER_DATE_EXAMPLE "Date: Thu, 01 Jan 2021 00:00:00 GMT\r\n"

Expand Down Expand Up @@ -423,7 +426,7 @@ write_content_from_json_generator(struct netconn* const p_conn, const http_serve
{
netconn_flags |= (uint8_t)NETCONN_MORE;
}
if (p_resp->content_len < 4 * 1024)
if (p_resp->content_len < HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FROM_JSON_GENERATOR)
{
LOG_INFO("json_stream_gen: send %u bytes:\n%s", num_bytes, p_chunk);
}
Expand All @@ -437,7 +440,7 @@ write_content_from_json_generator(struct netconn* const p_conn, const http_serve
LOG_ERR("%s failed", "http_server_netconn_write");
break;
}
vTaskDelay(pdMS_TO_TICKS(5));
vTaskDelay(pdMS_TO_TICKS(HTTP_SERVER_DELAY_BETWEEN_NETCONN_WRITE_MS)); // A delay to avoid triggering watchdog
}
json_stream_gen_delete(&p_json_gen);
}
Expand Down Expand Up @@ -908,7 +911,7 @@ http_server_netconn_serve_handle_req(
|| (HTTP_CONTENT_LOCATION_HEAP == resp.content_location)))
{
const size_t content_len = strlen((const char*)resp.select_location.memory.p_buf);
if (content_len <= HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG)
if (content_len <= HTTP_SERVER_MAX_CONTENT_LEN_TO_PRINT_LOG_FOR_JSON_RESP)
{
LOG_INFO("Json resp: code=%u, content:\n%s", resp.http_resp_code, resp.select_location.memory.p_buf);
}
Expand Down

0 comments on commit a8c824a

Please sign in to comment.