From fc1a41c627f25c1fa52c87d002d08870fa8876ac Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 13 May 2022 21:00:25 +0200 Subject: fix(minion): conform to the http/1.1 response syntax --- minion/src/wifi_module.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'minion/src/wifi_module.cpp') diff --git a/minion/src/wifi_module.cpp b/minion/src/wifi_module.cpp index 7c3e5bc..2f4e57c 100644 --- a/minion/src/wifi_module.cpp +++ b/minion/src/wifi_module.cpp @@ -329,11 +329,16 @@ auto WiFiModule::close_connection(size_t connection_id) noexcept -> bool return true; } -auto WiFiModule::send_response(size_t connection_id, const char *data) noexcept -> bool +auto WiFiModule::send_response( + size_t connection_id, + size_t status_code, + const char *data +) noexcept -> bool { const auto *cmd = "AT+CIPSEND"; - const auto data_length = strlen(data); + const auto data_length = strlen(RESPONSE_HTTP_VERSION) + 1 + + RESPONSE_STATUS_CODE_LENGTH + 4 + strlen(data); auto command_length = strlen(cmd) + 50U + data_length + 1U; @@ -355,6 +360,10 @@ auto WiFiModule::send_response(size_t connection_id, const char *data) noexcept _read(TIMEOUT_MEDIUM, response); + _serial.print(RESPONSE_HTTP_VERSION); + _serial.print(" "); + _serial.print(status_code); + _serial.print("\r\n\r\n"); _serial.print(data); strcpy(response, ""); -- cgit v1.2.3-18-g5258