Skip to content

Commit 3cac566

Browse files
authored
Merge pull request #4 from mafredri/header-fix
Use CRLF for spec compliant http headers
2 parents 1b8662d + 7f89203 commit 3cac566

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/wifi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,20 @@ uint16_t wifi_HttpGet(char *url) {
277277
}
278278
}
279279

280-
const char httpHeaderTpl[] = "HTTP/1.0 %d %s\n"
281-
"Server: OpenBttn\n"
282-
"Access-Control-Allow-Origin: *\n"
283-
"Content-Type: %s\n"
284-
"%s" // "Content-Encoding: %s\n"
285-
"Content-Length: %d\n\n";
280+
const char httpHeaderTpl[] = "HTTP/1.0 %d %s\r\n"
281+
"Server: OpenBttn\r\n"
282+
"Access-Control-Allow-Origin: *\r\n"
283+
"Content-Type: %s\r\n"
284+
"%s" // "Content-Encoding: %s\r\n"
285+
"Content-Length: %d\r\n\r\n";
286286

287287
int wifi_CreateHttpHeader(char *dest, int len, int status,
288288
const char *statusText, const char *contentType,
289289
const char *contentEnc, uint16_t contentLength) {
290290
char contentEncoding[HTTP_HEADER_ENCODING_LENGTH + 1] = {0};
291291
if (contentEnc) {
292292
int s = snprintf(contentEncoding, HTTP_HEADER_ENCODING_LENGTH,
293-
"Content-Encoding: %s\n", contentEnc);
293+
"Content-Encoding: %s\r\n", contentEnc);
294294
if (s < 0) {
295295
return s;
296296
}

src/wifi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464

6565
#define HTTP_HEADER_LENGTH 180
6666
#define HTTP_HEADER_ENCODING_LENGTH \
67-
(18 + 8) // Longest encodings are "compress" and "identity" (8 chars).
67+
(18 + 8 + 2) // Longest encodings are "compress" and "identity" (8 chars).
6868

6969
typedef uint16_t WifiState;
7070

0 commit comments

Comments
 (0)