Added Connection: close header (although not required by http/1.0 spec, it might work better for bad clients)
This commit is contained in:
+3
-3
@@ -191,7 +191,7 @@ int ICACHE_FLASH_ATTR httpdGetHeader(HttpdConnData *conn, char *header, char *re
|
||||
void ICACHE_FLASH_ATTR httpdStartResponse(HttpdConnData *conn, int code) {
|
||||
char buff[128];
|
||||
int l;
|
||||
l=os_sprintf(buff, "HTTP/1.0 %d OK\r\nServer: esp8266-httpd/"HTTPDVER"\r\n", code);
|
||||
l=os_sprintf(buff, "HTTP/1.0 %d OK\r\nServer: esp8266-httpd/"HTTPDVER"\r\nConnection: close\r\n", code);
|
||||
httpdSend(conn, buff, l);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ void ICACHE_FLASH_ATTR httpdEndHeaders(HttpdConnData *conn) {
|
||||
void ICACHE_FLASH_ATTR httpdRedirect(HttpdConnData *conn, char *newUrl) {
|
||||
char buff[1024];
|
||||
int l;
|
||||
l=os_sprintf(buff, "HTTP/1.1 302 Found\r\nLocation: %s\r\n\r\nMoved to %s\r\n", newUrl, newUrl);
|
||||
l=os_sprintf(buff, "HTTP/1.1 302 Found\r\nServer: esp8266-httpd/"HTTPDVER"\r\nConnection: close\r\nLocation: %s\r\n\r\nMoved to %s\r\n", newUrl, newUrl);
|
||||
httpdSend(conn, buff, l);
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ static void ICACHE_FLASH_ATTR httpdSentCb(void *arg) {
|
||||
xmitSendBuff(conn);
|
||||
}
|
||||
|
||||
static const char *httpNotFoundHeader="HTTP/1.0 404 Not Found\r\nServer: esp8266-httpd/"HTTPDVER"\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nNot Found.\r\n";
|
||||
static const char *httpNotFoundHeader="HTTP/1.0 404 Not Found\r\nServer: esp8266-httpd/"HTTPDVER"\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 12\r\n\r\nNot Found.\r\n";
|
||||
|
||||
//This is called when the headers have been received and the connection is ready to send
|
||||
//the result headers and data.
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ Connector to let httpd use the espfs filesystem to serve the files in it.
|
||||
|
||||
// The static files marked with FLAG_GZIP are compressed and will be served with GZIP compression.
|
||||
// If the client does not advertise that he accepts GZIP send following warning message (telnet users for e.g.)
|
||||
static const char *gzipNonSupportedMessage = "HTTP/1.0 501 Not implemented\r\nServer: esp8266-httpd/"HTTPDVER"\r\nContent-Type: text/plain\r\nContent-Length: 52\r\n\r\nYour browser does not accept gzip-compressed data.\r\n";
|
||||
static const char *gzipNonSupportedMessage = "HTTP/1.0 501 Not implemented\r\nServer: esp8266-httpd/"HTTPDVER"\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 52\r\n\r\nYour browser does not accept gzip-compressed data.\r\n";
|
||||
|
||||
|
||||
//This is a catch-all cgi function. It takes the url passed to it, looks up the corresponding
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) {
|
||||
if(connData->post->len > ESPFS_SIZE){
|
||||
// The uploaded file is too large
|
||||
os_printf("ESPFS file too large\n");
|
||||
httpdSend(connData, "HTTP/1.0 500 Internal Server Error\r\nServer: esp8266-httpd/0.3\r\nContent-Type: text/plain\r\nContent-Length: 24\r\n\r\nESPFS image loo large.\r\n", -1);
|
||||
httpdSend(connData, "HTTP/1.0 500 Internal Server Error\r\nServer: esp8266-httpd/0.3\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 24\r\n\r\nESPFS image loo large.\r\n", -1);
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user