mirror of
https://github.com/ep00ch/lwip-contrib-mac.git
synced 2024-09-29 09:54:52 +00:00
Moved some parts of the HTTP-header related code to a new file to share it between httpd.c and makefsdata.c, regenerated fsdata.c
This commit is contained in:
parent
4ec673b17d
commit
1f93022b83
@ -22,12 +22,11 @@ static const unsigned char data__img_sics_gif[] = {
|
||||
0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
|
||||
0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
|
||||
0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
|
||||
/* "Content-Type: image/gif
|
||||
" (25 bytes) */
|
||||
0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x3a,0x20,0x69,0x6d,
|
||||
0x61,0x67,0x65,0x2f,0x67,0x69,0x66,0x0d,0x0a,
|
||||
/* Empty line (end of header - 2 bytes) */
|
||||
0x0d,0x0a,
|
||||
/* "Content-type: image/gif
|
||||
|
||||
" (27 bytes) */
|
||||
0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x69,0x6d,
|
||||
0x61,0x67,0x65,0x2f,0x67,0x69,0x66,0x0d,0x0a,0x0d,0x0a,
|
||||
/* raw file data (724 bytes) */
|
||||
0x47,0x49,0x46,0x38,0x39,0x61,0x46,0x00,0x22,0x00,0xa5,0x00,0x00,0xd9,0x2b,0x39,
|
||||
0x6a,0x6a,0x6a,0xbf,0xbf,0xbf,0x93,0x93,0x93,0x0f,0x0f,0x0f,0xb0,0xb0,0xb0,0xa6,
|
||||
@ -92,12 +91,11 @@ static const unsigned char data__404_html[] = {
|
||||
0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
|
||||
0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
|
||||
0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
|
||||
/* "Content-Type: text/html
|
||||
" (25 bytes) */
|
||||
0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
|
||||
0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,
|
||||
/* Empty line (end of header - 2 bytes) */
|
||||
0x0d,0x0a,
|
||||
/* "Content-type: text/html
|
||||
|
||||
" (27 bytes) */
|
||||
0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
|
||||
0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a,
|
||||
/* raw file data (565 bytes) */
|
||||
0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a,0x3c,0x68,0x65,0x61,0x64,0x3e,0x3c,0x74,
|
||||
0x69,0x74,0x6c,0x65,0x3e,0x6c,0x77,0x49,0x50,0x20,0x2d,0x20,0x41,0x20,0x4c,0x69,
|
||||
@ -152,12 +150,11 @@ static const unsigned char data__index_html[] = {
|
||||
0x2e,0x31,0x20,0x28,0x68,0x74,0x74,0x70,0x3a,0x2f,0x2f,0x73,0x61,0x76,0x61,0x6e,
|
||||
0x6e,0x61,0x68,0x2e,0x6e,0x6f,0x6e,0x67,0x6e,0x75,0x2e,0x6f,0x72,0x67,0x2f,0x70,
|
||||
0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6c,0x77,0x69,0x70,0x29,0x0d,0x0a,
|
||||
/* "Content-Type: text/html
|
||||
" (25 bytes) */
|
||||
0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x54,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
|
||||
0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,
|
||||
/* Empty line (end of header - 2 bytes) */
|
||||
0x0d,0x0a,
|
||||
/* "Content-type: text/html
|
||||
|
||||
" (27 bytes) */
|
||||
0x43,0x6f,0x6e,0x74,0x65,0x6e,0x74,0x2d,0x74,0x79,0x70,0x65,0x3a,0x20,0x74,0x65,
|
||||
0x78,0x74,0x2f,0x68,0x74,0x6d,0x6c,0x0d,0x0a,0x0d,0x0a,
|
||||
/* raw file data (1583 bytes) */
|
||||
0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a,0x3c,0x68,0x65,0x61,0x64,0x3e,0x3c,0x74,
|
||||
0x69,0x74,0x6c,0x65,0x3e,0x6c,0x77,0x49,0x50,0x20,0x2d,0x20,0x41,0x20,0x4c,0x69,
|
||||
|
@ -37,6 +37,7 @@ struct fsdata_file {
|
||||
const unsigned char *name;
|
||||
const unsigned char *data;
|
||||
int len;
|
||||
int http_header_included;
|
||||
};
|
||||
|
||||
#endif /* __FSDATA_H__ */
|
||||
|
@ -86,6 +86,7 @@
|
||||
#include "lwip/debug.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd_structs.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "fs.h"
|
||||
|
||||
@ -95,14 +96,6 @@
|
||||
#define HTTPD_DEBUG LWIP_DBG_ON
|
||||
#endif
|
||||
|
||||
#ifndef HTTPD_SERVER_AGENT
|
||||
#define HTTPD_SERVER_AGENT "lwIP/1.3.1 (http://www.sics.se/~adam/lwip/)"
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_HTTPD_DYNAMIC_HEADERS
|
||||
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
|
||||
#endif
|
||||
|
||||
/** Set this to 1 and add the next line to lwippools.h to use a memp pool
|
||||
* for allocating struct http_state instead of the heap:
|
||||
*
|
||||
@ -243,85 +236,6 @@ const tCGI *g_pCGIs = NULL;
|
||||
int g_iNumCGIs = 0;
|
||||
#endif /* LWIP_HTTPD_CGI */
|
||||
|
||||
#if LWIP_HTTPD_DYNAMIC_HEADERS
|
||||
/*****************************************************************************
|
||||
* HTTP header strings for various filename extensions.
|
||||
*
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
const char *pszExtension;
|
||||
unsigned long ulHeaderIndex;
|
||||
} tHTTPHeader;
|
||||
|
||||
const char *g_psHTTPHeaderStrings[] =
|
||||
{
|
||||
"Content-type: text/html\r\n\r\n",
|
||||
"Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\n" \
|
||||
"Pragma: no-cache\r\n\r\n",
|
||||
"Content-type: image/gif\r\n\r\n",
|
||||
"Content-type: image/png\r\n\r\n",
|
||||
"Content-type: image/jpeg\r\n\r\n",
|
||||
"Content-type: image/bmp\r\n\r\n",
|
||||
"Content-type: image/x-icon\r\n\r\n",
|
||||
"Content-type: application/octet-stream\r\n\r\n",
|
||||
"Content-type: application/x-javascript\r\n\r\n",
|
||||
"Content-type: application/x-javascript\r\n\r\n",
|
||||
"Content-type: text/css\r\n\r\n",
|
||||
"Content-type: application/x-shockwave-flash\r\n\r\n",
|
||||
"Content-type: text/xml\r\n\r\n",
|
||||
"Content-type: text/plain\r\n\r\n",
|
||||
"HTTP/1.0 200 OK\r\n",
|
||||
"HTTP/1.0 404 File not found\r\n",
|
||||
"Server: "HTTPD_SERVER_AGENT"\r\n",
|
||||
"\r\n<html><body><h2>404: The requested file cannot be found." \
|
||||
"</h2></body></html>\r\n"
|
||||
};
|
||||
|
||||
#define HTTP_HDR_HTML 0 /* text/html */
|
||||
#define HTTP_HDR_SSI 1 /* text/html Expires... */
|
||||
#define HTTP_HDR_GIF 2 /* image/gif */
|
||||
#define HTTP_HDR_PNG 3 /* image/png */
|
||||
#define HTTP_HDR_JPG 4 /* image/jpeg */
|
||||
#define HTTP_HDR_BMP 5 /* image/bmp */
|
||||
#define HTTP_HDR_ICO 6 /* image/x-icon */
|
||||
#define HTTP_HDR_APP 7 /* application/octet-stream */
|
||||
#define HTTP_HDR_JS 8 /* application/x-javascript */
|
||||
#define HTTP_HDR_RA 9 /* application/x-javascript */
|
||||
#define HTTP_HDR_CSS 10 /* text/css */
|
||||
#define HTTP_HDR_SWF 11 /* application/x-shockwave-flash */
|
||||
#define HTTP_HDR_XML 12 /* text/xml */
|
||||
#define HTTP_HDR_DEFAULT_TYPE 13 /* text/plain */
|
||||
#define HTTP_HDR_OK 14 /* 200 OK */
|
||||
#define HTTP_HDR_NOT_FOUND 15 /* 404 File not found */
|
||||
#define HTTP_HDR_SERVER 16 /* Server: HTTPD_SERVER_AGENT */
|
||||
#define DEFAULT_404_HTML 17 /* default 404 body */
|
||||
|
||||
tHTTPHeader g_psHTTPHeaders[] =
|
||||
{
|
||||
{ "html", HTTP_HDR_HTML},
|
||||
{ "htm", HTTP_HDR_HTML},
|
||||
{ "shtml",HTTP_HDR_SSI},
|
||||
{ "shtm", HTTP_HDR_SSI},
|
||||
{ "ssi", HTTP_HDR_SSI},
|
||||
{ "gif", HTTP_HDR_GIF},
|
||||
{ "png", HTTP_HDR_PNG},
|
||||
{ "jpg", HTTP_HDR_JPG},
|
||||
{ "bmp", HTTP_HDR_BMP},
|
||||
{ "ico", HTTP_HDR_ICO},
|
||||
{ "class",HTTP_HDR_APP},
|
||||
{ "cls", HTTP_HDR_APP},
|
||||
{ "js", HTTP_HDR_JS},
|
||||
{ "ram", HTTP_HDR_RA},
|
||||
{ "css", HTTP_HDR_CSS},
|
||||
{ "swf", HTTP_HDR_SWF},
|
||||
{ "xml", HTTP_HDR_XML}
|
||||
};
|
||||
|
||||
#define NUM_HTTP_HEADERS (sizeof(g_psHTTPHeaders) / sizeof(tHTTPHeader))
|
||||
|
||||
#endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
|
||||
|
||||
/** Allocate a struct http_state. */
|
||||
static struct http_state*
|
||||
http_state_alloc()
|
||||
|
@ -36,6 +36,8 @@
|
||||
#ifndef __HTTPD_H__
|
||||
#define __HTTPD_H__
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
void httpd_init(void);
|
||||
|
||||
#ifndef LWIP_HTTPD_CGI
|
||||
|
94
apps/httpserver_raw/httpd_structs.h
Normal file
94
apps/httpserver_raw/httpd_structs.h
Normal file
@ -0,0 +1,94 @@
|
||||
#ifndef __HTTPD_STRUCTS_H__
|
||||
#define __HTTPD_STRUCTS_H__
|
||||
|
||||
#include "httpd.h"
|
||||
|
||||
#ifndef HTTPD_SERVER_AGENT
|
||||
#define HTTPD_SERVER_AGENT "lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)"
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_HTTPD_DYNAMIC_HEADERS
|
||||
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
|
||||
#endif
|
||||
|
||||
|
||||
#if LWIP_HTTPD_DYNAMIC_HEADERS
|
||||
/*****************************************************************************
|
||||
* HTTP header strings for various filename extensions.
|
||||
*
|
||||
*****************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
const char *pszExtension;
|
||||
unsigned long ulHeaderIndex;
|
||||
} tHTTPHeader;
|
||||
|
||||
static const char *g_psHTTPHeaderStrings[] =
|
||||
{
|
||||
"Content-type: text/html\r\n\r\n",
|
||||
"Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\n" \
|
||||
"Pragma: no-cache\r\n\r\n",
|
||||
"Content-type: image/gif\r\n\r\n",
|
||||
"Content-type: image/png\r\n\r\n",
|
||||
"Content-type: image/jpeg\r\n\r\n",
|
||||
"Content-type: image/bmp\r\n\r\n",
|
||||
"Content-type: image/x-icon\r\n\r\n",
|
||||
"Content-type: application/octet-stream\r\n\r\n",
|
||||
"Content-type: application/x-javascript\r\n\r\n",
|
||||
"Content-type: application/x-javascript\r\n\r\n",
|
||||
"Content-type: text/css\r\n\r\n",
|
||||
"Content-type: application/x-shockwave-flash\r\n\r\n",
|
||||
"Content-type: text/xml\r\n\r\n",
|
||||
"Content-type: text/plain\r\n\r\n",
|
||||
"HTTP/1.0 200 OK\r\n",
|
||||
"HTTP/1.0 404 File not found\r\n",
|
||||
"Server: "HTTPD_SERVER_AGENT"\r\n",
|
||||
"\r\n<html><body><h2>404: The requested file cannot be found." \
|
||||
"</h2></body></html>\r\n"
|
||||
};
|
||||
|
||||
#define HTTP_HDR_HTML 0 /* text/html */
|
||||
#define HTTP_HDR_SSI 1 /* text/html Expires... */
|
||||
#define HTTP_HDR_GIF 2 /* image/gif */
|
||||
#define HTTP_HDR_PNG 3 /* image/png */
|
||||
#define HTTP_HDR_JPG 4 /* image/jpeg */
|
||||
#define HTTP_HDR_BMP 5 /* image/bmp */
|
||||
#define HTTP_HDR_ICO 6 /* image/x-icon */
|
||||
#define HTTP_HDR_APP 7 /* application/octet-stream */
|
||||
#define HTTP_HDR_JS 8 /* application/x-javascript */
|
||||
#define HTTP_HDR_RA 9 /* application/x-javascript */
|
||||
#define HTTP_HDR_CSS 10 /* text/css */
|
||||
#define HTTP_HDR_SWF 11 /* application/x-shockwave-flash */
|
||||
#define HTTP_HDR_XML 12 /* text/xml */
|
||||
#define HTTP_HDR_DEFAULT_TYPE 13 /* text/plain */
|
||||
#define HTTP_HDR_OK 14 /* 200 OK */
|
||||
#define HTTP_HDR_NOT_FOUND 15 /* 404 File not found */
|
||||
#define HTTP_HDR_SERVER 16 /* Server: HTTPD_SERVER_AGENT */
|
||||
#define DEFAULT_404_HTML 17 /* default 404 body */
|
||||
|
||||
static tHTTPHeader g_psHTTPHeaders[] =
|
||||
{
|
||||
{ "html", HTTP_HDR_HTML},
|
||||
{ "htm", HTTP_HDR_HTML},
|
||||
{ "shtml",HTTP_HDR_SSI},
|
||||
{ "shtm", HTTP_HDR_SSI},
|
||||
{ "ssi", HTTP_HDR_SSI},
|
||||
{ "gif", HTTP_HDR_GIF},
|
||||
{ "png", HTTP_HDR_PNG},
|
||||
{ "jpg", HTTP_HDR_JPG},
|
||||
{ "bmp", HTTP_HDR_BMP},
|
||||
{ "ico", HTTP_HDR_ICO},
|
||||
{ "class",HTTP_HDR_APP},
|
||||
{ "cls", HTTP_HDR_APP},
|
||||
{ "js", HTTP_HDR_JS},
|
||||
{ "ram", HTTP_HDR_RA},
|
||||
{ "css", HTTP_HDR_CSS},
|
||||
{ "swf", HTTP_HDR_SWF},
|
||||
{ "xml", HTTP_HDR_XML}
|
||||
};
|
||||
|
||||
#define NUM_HTTP_HEADERS (sizeof(g_psHTTPHeaders) / sizeof(tHTTPHeader))
|
||||
|
||||
#endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
|
||||
|
||||
#endif /* __HTTPD_STRUCTS_H__ */
|
@ -57,11 +57,10 @@
|
||||
|
||||
/* define this to get the header variables we use to build HTTP headers */
|
||||
#define LWIP_HTTPD_DYNAMIC_HEADERS 1
|
||||
#include "../httpd.c"
|
||||
#include "../httpd_structs.h"
|
||||
|
||||
/** (Your server name here) */
|
||||
const char *serverID =
|
||||
"Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)\r\n";
|
||||
const char *serverID = "Server: "HTTPD_SERVER_AGENT"\r\n";
|
||||
|
||||
/* change this to suit your MEM_ALIGNMENT */
|
||||
#define PAYLOAD_ALIGNMENT 4
|
||||
@ -381,8 +380,11 @@ int file_write_http_header(FILE *data_file, const char *filename, int file_size)
|
||||
LWIP_UNUSED_ARG(file_size);
|
||||
#endif
|
||||
|
||||
/* empty line already included in content-type line */
|
||||
#if 0
|
||||
fprintf(data_file, NEWLINE "/* Empty line (end of header - 2 bytes) */" NEWLINE, cur_string);
|
||||
written += file_put_ascii(data_file, "\r\n", 2, &i);
|
||||
#endif
|
||||
|
||||
return written;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user