From 7f8920307fa9698d8f8a70881cb553e7e10473d8 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Sun, 4 Jun 2017 11:15:04 +0300 Subject: [PATCH] Use CRLF for spec compliant http headers --- src/wifi.c | 14 +++++++------- src/wifi.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wifi.c b/src/wifi.c index 6a03844..e709745 100644 --- a/src/wifi.c +++ b/src/wifi.c @@ -277,12 +277,12 @@ uint16_t wifi_HttpGet(char *url) { } } -const char httpHeaderTpl[] = "HTTP/1.0 %d %s\n" - "Server: OpenBttn\n" - "Access-Control-Allow-Origin: *\n" - "Content-Type: %s\n" - "%s" // "Content-Encoding: %s\n" - "Content-Length: %d\n\n"; +const char httpHeaderTpl[] = "HTTP/1.0 %d %s\r\n" + "Server: OpenBttn\r\n" + "Access-Control-Allow-Origin: *\r\n" + "Content-Type: %s\r\n" + "%s" // "Content-Encoding: %s\r\n" + "Content-Length: %d\r\n\r\n"; int wifi_CreateHttpHeader(char *dest, int len, int status, const char *statusText, const char *contentType, @@ -290,7 +290,7 @@ int wifi_CreateHttpHeader(char *dest, int len, int status, char contentEncoding[HTTP_HEADER_ENCODING_LENGTH + 1] = {0}; if (contentEnc) { int s = snprintf(contentEncoding, HTTP_HEADER_ENCODING_LENGTH, - "Content-Encoding: %s\n", contentEnc); + "Content-Encoding: %s\r\n", contentEnc); if (s < 0) { return s; } diff --git a/src/wifi.h b/src/wifi.h index 0bf96a7..f0e7367 100644 --- a/src/wifi.h +++ b/src/wifi.h @@ -64,7 +64,7 @@ #define HTTP_HEADER_LENGTH 180 #define HTTP_HEADER_ENCODING_LENGTH \ - (18 + 8) // Longest encodings are "compress" and "identity" (8 chars). + (18 + 8 + 2) // Longest encodings are "compress" and "identity" (8 chars). typedef uint16_t WifiState;