Common stuff for all my devices' web server pages: css, login, log, ipv4, ipv6, firmware update, clock, reset info etc.
Dependents: oldheating gps motorhome heating
http-ok.c
00001 #include "log.h" 00002 #include "http.h" 00003 00004 char* HttpOkCookieName; 00005 char* HttpOkCookieValue; 00006 int HttpOkCookieMaxAge = -1; //-1 = none, 0 = clear, +ve values = number of seconds 00007 00008 void HttpOk(const char* contentType, const char* cacheControl, const char* lastModifiedDate, const char* lastModifiedTime) 00009 { 00010 char pDate[HTTP_DATE_LENGTH]; 00011 00012 if (!contentType) LogTimeF("HtmlOk - missing Content-Type info\r\n"); 00013 if (!cacheControl) LogTimeF("HtmlOk - missing Cache-Control info\r\n"); 00014 00015 HttpAddF("HTTP/1.1 200 OK\r\n" 00016 "Connection: close\r\n" 00017 "Content-Type: %s\r\n", contentType); 00018 00019 HttpAddF("Cache-Control: %s\r\n", cacheControl); 00020 00021 HttpDateFromNow(pDate); 00022 HttpAddF("Date: %s\r\n", pDate); 00023 00024 if (lastModifiedDate) 00025 { 00026 HttpDateFromDateTime(lastModifiedDate, lastModifiedTime, pDate); 00027 HttpAddF("Last-Modified: %s\r\n", pDate); 00028 } 00029 00030 if (HttpOkCookieName && HttpOkCookieValue) 00031 { 00032 HttpAddF("Set-Cookie: %s=%s", HttpOkCookieName, HttpOkCookieValue ); 00033 if (HttpOkCookieMaxAge >= 0) HttpAddF("; Max-Age=%d", HttpOkCookieMaxAge); 00034 HttpAddText("\r\n"); 00035 } 00036 00037 HttpAddText("\r\n"); 00038 }
Generated on Wed Jul 13 2022 14:19:59 by 1.7.2