Prusa MINI Firmware overview
httpd_structs.h
Go to the documentation of this file.
1 #ifndef LWIP_HTTPD_STRUCTS_H
2 #define LWIP_HTTPD_STRUCTS_H
3 
4 #include "lwip/apps/httpd.h"
5 
6 #if LWIP_HTTPD_DYNAMIC_HEADERS
7 /** This struct is used for a list of HTTP header strings for various
8  * filename extensions. */
9 typedef struct
10 {
11  const char *extension;
12  const char *content_type;
13 } tHTTPHeader;
14 
15 /** A list of strings used in HTTP headers (see RFC 1945 HTTP/1.0 and
16  * RFC 2616 HTTP/1.1 for header field definitions) */
17 static const char * const g_psHTTPHeaderStrings[] =
18 {
19  "HTTP/1.0 200 OK\r\n",
20  "HTTP/1.0 404 File not found\r\n",
21  "HTTP/1.0 400 Bad Request\r\n",
22  "HTTP/1.0 501 Not Implemented\r\n",
23  "HTTP/1.1 200 OK\r\n",
24  "HTTP/1.1 404 File not found\r\n",
25  "HTTP/1.1 400 Bad Request\r\n",
26  "HTTP/1.1 501 Not Implemented\r\n",
27  "Content-Length: ",
28  "Connection: Close\r\n",
29  "Connection: keep-alive\r\n",
30  "Connection: keep-alive\r\nContent-Length: ",
31  "Server: "HTTPD_SERVER_AGENT"\r\n",
32  "\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
33 #if LWIP_HTTPD_SUPPORT_11_KEEPALIVE
34  ,"Connection: keep-alive\r\nContent-Length: 77\r\n\r\n<html><body><h2>404: The requested file cannot be found.</h2></body></html>\r\n"
35 #endif
36 };
37 
38 /* Indexes into the g_psHTTPHeaderStrings array */
39 #define HTTP_HDR_OK 0 /* 200 OK */
40 #define HTTP_HDR_NOT_FOUND 1 /* 404 File not found */
41 #define HTTP_HDR_BAD_REQUEST 2 /* 400 Bad request */
42 #define HTTP_HDR_NOT_IMPL 3 /* 501 Not Implemented */
43 #define HTTP_HDR_OK_11 4 /* 200 OK */
44 #define HTTP_HDR_NOT_FOUND_11 5 /* 404 File not found */
45 #define HTTP_HDR_BAD_REQUEST_11 6 /* 400 Bad request */
46 #define HTTP_HDR_NOT_IMPL_11 7 /* 501 Not Implemented */
47 #define HTTP_HDR_CONTENT_LENGTH 8 /* Content-Length: (HTTP 1.0)*/
48 #define HTTP_HDR_CONN_CLOSE 9 /* Connection: Close (HTTP 1.1) */
49 #define HTTP_HDR_CONN_KEEPALIVE 10 /* Connection: keep-alive (HTTP 1.1) */
50 #define HTTP_HDR_KEEPALIVE_LEN 11 /* Connection: keep-alive + Content-Length: (HTTP 1.1)*/
51 #define HTTP_HDR_SERVER 12 /* Server: HTTPD_SERVER_AGENT */
52 #define DEFAULT_404_HTML 13 /* default 404 body */
53 #if LWIP_HTTPD_SUPPORT_11_KEEPALIVE
54 #define DEFAULT_404_HTML_PERSISTENT 14 /* default 404 body, but including Connection: keep-alive */
55 #endif
56 
57 
58 #define HTTP_HDR_HTML "Content-type: text/html\r\n\r\n"
59 #define HTTP_HDR_SSI "Content-type: text/html\r\nExpires: Fri, 10 Apr 2008 14:00:00 GMT\r\nPragma: no-cache\r\n\r\n"
60 #define HTTP_HDR_GIF "Content-type: image/gif\r\n\r\n"
61 #define HTTP_HDR_PNG "Content-type: image/png\r\n\r\n"
62 #define HTTP_HDR_JPG "Content-type: image/jpeg\r\n\r\n"
63 #define HTTP_HDR_BMP "Content-type: image/bmp\r\n\r\n"
64 #define HTTP_HDR_ICO "Content-type: image/x-icon\r\n\r\n"
65 #define HTTP_HDR_APP "Content-type: application/octet-stream\r\n\r\n"
66 #define HTTP_HDR_JS "Content-type: application/javascript\r\n\r\n"
67 #define HTTP_HDR_RA "Content-type: application/javascript\r\n\r\n"
68 #define HTTP_HDR_CSS "Content-type: text/css\r\n\r\n"
69 #define HTTP_HDR_SWF "Content-type: application/x-shockwave-flash\r\n\r\n"
70 #define HTTP_HDR_XML "Content-type: text/xml\r\n\r\n"
71 #define HTTP_HDR_PDF "Content-type: application/pdf\r\n\r\n"
72 #define HTTP_HDR_JSON "Content-type: application/json\r\n\r\n"
73 
74 #define HTTP_HDR_DEFAULT_TYPE "Content-type: text/plain\r\n\r\n"
75 
76 /** A list of extension-to-HTTP header strings (see outdated RFC 1700 MEDIA TYPES
77  * and http://www.iana.org/assignments/media-types for registered content types
78  * and subtypes) */
79 static const tHTTPHeader g_psHTTPHeaders[] =
80 {
81  { "html", HTTP_HDR_HTML},
82  { "htm", HTTP_HDR_HTML},
83  { "shtml",HTTP_HDR_SSI},
84  { "shtm", HTTP_HDR_SSI},
85  { "ssi", HTTP_HDR_SSI},
86  { "gif", HTTP_HDR_GIF},
87  { "png", HTTP_HDR_PNG},
88  { "jpg", HTTP_HDR_JPG},
89  { "bmp", HTTP_HDR_BMP},
90  { "ico", HTTP_HDR_ICO},
91  { "class",HTTP_HDR_APP},
92  { "cls", HTTP_HDR_APP},
93  { "js", HTTP_HDR_JS},
94  { "ram", HTTP_HDR_RA},
95  { "css", HTTP_HDR_CSS},
96  { "swf", HTTP_HDR_SWF},
97  { "xml", HTTP_HDR_XML},
98  { "xsl", HTTP_HDR_XML},
99  { "pdf", HTTP_HDR_PDF},
100  { "json", HTTP_HDR_JSON}
101 };
102 
103 #define NUM_HTTP_HEADERS (sizeof(g_psHTTPHeaders) / sizeof(tHTTPHeader))
104 
105 #endif /* LWIP_HTTPD_DYNAMIC_HEADERS */
106 
107 #if LWIP_HTTPD_SSI
108 static const char * const g_pcSSIExtensions[] = {
109  ".shtml", ".shtm", ".ssi", ".xml"
110 };
111 #define NUM_SHTML_EXTENSIONS (sizeof(g_pcSSIExtensions) / sizeof(const char *))
112 #endif /* LWIP_HTTPD_SSI */
113 
114 #endif /* LWIP_HTTPD_STRUCTS_H */
HTTPD_TCP_PRIO
#define HTTPD_TCP_PRIO
Definition: httpd_opts.h:152
HTTPD_MAX_WRITE_LEN
#define HTTPD_MAX_WRITE_LEN(pcb)
Definition: httpd_opts.h:266
pbuf::len
u16_t len
Definition: pbuf.h:159
LWIP_HTTPD_REQ_BUFSIZE
#define LWIP_HTTPD_REQ_BUFSIZE
Definition: httpd_opts.h:198
fs_file::len
int len
Definition: fs.h:58
s16_t
int16_t s16_t
Definition: arch.h:122
def.h
file__status_prnflow_svg
const struct fsdata_file file__status_prnflow_svg[]
Definition: fsdata_custom.c:5077
LWIP_ASSERT
#define LWIP_ASSERT(message, assertion)
Definition: debug.h:116
fs.h
PBUF_RAW
Definition: pbuf.h:94
file__status_heatbed_svg
const struct fsdata_file file__status_heatbed_svg[]
Definition: fsdata_custom.c:5061
ERR_ABRT
Definition: err.h:90
HTTPD_MAX_RETRIES
#define HTTPD_MAX_RETRIES
Definition: httpd_opts.h:140
u16_t
uint16_t u16_t
Definition: arch.h:121
fs_open
err_t fs_open(struct fs_file *file, const char *name)
Definition: fs.c:62
file__spool_color_svg
const struct fsdata_file file__spool_color_svg[]
Definition: fsdata_custom.c:5045
pbuf::tot_len
u16_t tot_len
Definition: pbuf.h:156
file__404_html
const struct fsdata_file file__404_html[]
Definition: fsdata_custom.c:4981
IP_ANY_TYPE
#define IP_ANY_TYPE
Definition: ip_addr.h:400
LWIP_MEMPOOL_INIT
#define LWIP_MEMPOOL_INIT(name)
Definition: memp.h:117
TCP_SND_QUEUELEN
#define TCP_SND_QUEUELEN
Definition: opt.h:1212
data
uint8_t data[8]
Definition: masstorage.h:49
u32_t
uint32_t u32_t
Definition: arch.h:123
LWIP_HTTPD_REQ_QUEUELEN
#define LWIP_HTTPD_REQ_QUEUELEN
Definition: httpd_opts.h:192
i
uint8_t i
Definition: screen_test_graph.c:72
file__heated_bed_color_svg
const struct fsdata_file file__heated_bed_color_svg[]
Definition: fsdata_custom.c:5005
pbuf::next
struct pbuf * next
Definition: pbuf.h:144
fs_file
Definition: fs.h:56
pbuf_free
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:715
data__404_html
static const unsigned char data__404_html[]
Definition: fsdata.c:79
init.h
LWIP_DBG_TRACE
#define LWIP_DBG_TRACE
Definition: debug.h:83
httpd.h
file__connect_black_svg
const struct fsdata_file file__connect_black_svg[]
Definition: fsdata_custom.c:4997
file_NULL
#define file_NULL
Definition: fsdata_custom.c:6
file__z_axis_color_svg
const struct fsdata_file file__z_axis_color_svg[]
Definition: fsdata_custom.c:5101
lwip_strnstr
char * lwip_strnstr(const char *buffer, const char *token, size_t n)
Definition: def.c:105
FSDATA_ALIGN_PRE
#define FSDATA_ALIGN_PRE
Definition: fsdata_custom.c:20
CRLF
#define CRLF
Definition: connection.hpp:7
S32_F
#define S32_F
Definition: arch.h:155
NULL
#define NULL
Definition: usbd_def.h:53
LWIP_MIN
#define LWIP_MIN(x, y)
Definition: def.h:55
file__status_z_axis_svg
const struct fsdata_file file__status_z_axis_svg[]
Definition: fsdata_custom.c:5093
file__index_js
const struct fsdata_file file__index_js[]
Definition: fsdata_custom.c:5029
ERR_INPROGRESS
Definition: err.h:73
HTTP_IS_TAG_VOLATILE
#define HTTP_IS_TAG_VOLATILE(ptr)
Definition: httpd_opts.h:253
stats.h
ERR_MEM
Definition: err.h:65
pbuf_copy_partial
u16_t pbuf_copy_partial(const struct pbuf *buf, void *dataptr, u16_t len, u16_t offset)
Definition: pbuf.c:1015
file__index_css
const struct fsdata_file file__index_css[]
Definition: fsdata_custom.c:5013
fs_close
void fs_close(struct fs_file *file)
Definition: fs.c:101
loop
void loop(void)
Definition: Marlin.cpp:1127
pbuf_alloc
struct pbuf * pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
Definition: pbuf.c:248
dummy_align__404_html
static const unsigned int dummy_align__404_html
Definition: fsdata.c:78
data__index_html
static const unsigned char data__index_html[]
Definition: fsdata.c:138
pbuf_clen
u16_t pbuf_clen(const struct pbuf *p)
Definition: pbuf.c:800
u8_t
uint8_t u8_t
Definition: arch.h:119
FS_FILE_FLAGS_HEADER_PERSISTENT
#define FS_FILE_FLAGS_HEADER_PERSISTENT
Definition: fsdata_custom.c:13
file__status_prnspeed_svg
const struct fsdata_file file__status_prnspeed_svg[]
Definition: fsdata_custom.c:5085
sys_now
u32_t sys_now(void)
Returns the current time in milliseconds when LWIP_TIMERS == 1 and NO_SYS == 1.
Definition: ethernetif.c:616
file__status_filament_svg
const struct fsdata_file file__status_filament_svg[]
Definition: fsdata_custom.c:5053
LWIP_MAX
#define LWIP_MAX(x, y)
Definition: def.h:54
LWIP_HTTPD_SSI_MULTIPART
#define LWIP_HTTPD_SSI_MULTIPART
Definition: httpd_opts.h:88
dummy_align__index_html
static const unsigned int dummy_align__index_html
Definition: fsdata.c:137
ERR_ARG
Definition: err.h:96
LWIP_UNUSED_ARG
#define LWIP_UNUSED_ARG(x)
Definition: arch.h:308
fs_file::data
const char * data
Definition: fs.h:57
LWIP_HTTPD_MAX_REQ_LENGTH
#define LWIP_HTTPD_MAX_REQ_LENGTH
Definition: httpd_opts.h:205
if
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
pbuf_ref
void pbuf_ref(struct pbuf *p)
Definition: pbuf.c:820
pbuf_cat
void pbuf_cat(struct pbuf *h, struct pbuf *t)
Definition: pbuf.c:840
LWIP_HTTPD_MAX_CGI_PARAMETERS
#define LWIP_HTTPD_MAX_CGI_PARAMETERS
Definition: httpd_opts.h:80
MEMCPY
#define MEMCPY(dst, src, len)
Definition: opt.h:137
U16_F
#define U16_F
Definition: arch.h:143
HTTPD_DEBUG_TIMING
#define HTTPD_DEBUG_TIMING
Definition: httpd_opts.h:161
ERR_OK
Definition: err.h:63
HTTPD_SERVER_PORT
#define HTTPD_SERVER_PORT
Definition: httpd_opts.h:132
err_t
s8_t err_t
Definition: err.h:57
FSDATA_ALIGN_POST
#define FSDATA_ALIGN_POST
Definition: fsdata_custom.c:23
lwip_itoa
void lwip_itoa(char *result, size_t bufsize, int number)
Definition: def.c:198
ip.h
LWIP_HTTPD_SSI_RAW
#define LWIP_HTTPD_SSI_RAW
Definition: httpd_opts.h:70
HTTPD_SERVER_AGENT
#define HTTPD_SERVER_AGENT
Definition: httpd_opts.h:107
SMEMCPY
#define SMEMCPY(dst, src, len)
Definition: opt.h:145
tcp.h
file__speed_color_svg
const struct fsdata_file file__speed_color_svg[]
Definition: fsdata_custom.c:5037
file__index_html
const struct fsdata_file file__index_html[]
Definition: fsdata_custom.c:5021
fsdata.h
HTTPD_DEBUG
#define HTTPD_DEBUG
Definition: httpd_opts.h:120
LWIP_HTTPD_MAX_TAG_INSERT_LEN
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN
Definition: httpd_opts.h:98
FS_READ_DELAYED
#define FS_READ_DELAYED
Definition: fs.h:43
fsdata_file
Definition: fsdata.h:38
lwip_stricmp
int lwip_stricmp(const char *str1, const char *str2)
Definition: def.c:128
LWIP_MEMPOOL_DECLARE
#define LWIP_MEMPOOL_DECLARE(name, num, size, desc)
Definition: memp.h:95
LWIP_DBG_LEVEL_WARNING
#define LWIP_DBG_LEVEL_WARNING
Definition: debug.h:55
mem_malloc
void * mem_malloc(mem_size_t size)
Definition: mem.c:603
pbuf_header
u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment)
Definition: pbuf.c:665
FS_FILE_FLAGS_HEADER_INCLUDED
#define FS_FILE_FLAGS_HEADER_INCLUDED
Definition: fsdata_custom.c:10
fs_file::is_custom_file
u8_t is_custom_file
Definition: fs.h:67
U32_F
#define U32_F
Definition: arch.h:152
sys.h
mem_size_t
u16_t mem_size_t
Definition: mem.h:67
fsdata_file::name
const unsigned char * name
Definition: fsdata.h:40
fs_bytes_left
int fs_bytes_left(struct fs_file *file)
Definition: fs.c:176
ERR_USE
Definition: err.h:79
HTTPD_POLL_INTERVAL
#define HTTPD_POLL_INTERVAL
Definition: httpd_opts.h:145
length
png_uint_32 length
Definition: png.c:2247
mem_free
void mem_free(void *rmem)
Definition: mem.c:419
httpd_init
void httpd_init(void)
httpd_structs.h
IPADDR_TYPE_ANY
Definition: ip_addr.h:60
ERR_VAL
Definition: err.h:75
pbuf
Definition: pbuf.h:142
LWIP_DEBUGF
#define LWIP_DEBUGF(debug, message)
Definition: debug.h:164
LWIP_HTTPD_MAX_TAG_NAME_LEN
#define LWIP_HTTPD_MAX_TAG_NAME_LEN
Definition: httpd_opts.h:93
LWIP_HTTPD_FILE_STATE
#define LWIP_HTTPD_FILE_STATE
Definition: httpd_opts.h:295
LWIP_HTTPD_POST_MANUAL_WND
#define LWIP_HTTPD_POST_MANUAL_WND
Definition: httpd_opts.h:102
file__calibration_color_svg
const struct fsdata_file file__calibration_color_svg[]
Definition: fsdata_custom.c:4989
debug.h
PBUF_REF
Definition: pbuf.h:116
pbuf::payload
void * payload
Definition: pbuf.h:147
lwip_strerr
#define lwip_strerr(x)
Definition: err.h:108
file__status_nozzle_svg
const struct fsdata_file file__status_nozzle_svg[]
Definition: fsdata_custom.c:5069