WIZlib Library API  ver 1.0
WIZlib Library API User Menual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
httpd.h
Go to the documentation of this file.
1 
12 #ifndef __HTTPD_H__
13 #define __HTTPD_H__
14 
15 #include "common/common.h"
16 #include "romfile.h"
17 
18 
19 #define HTTP_SERVER_PORT 80
21 /* HTTP Method */
22 #define METHOD_ERR 0
23 #define METHOD_GET 1
24 #define METHOD_HEAD 2
25 #define METHOD_POST 3
27 /* HTTP GET Method */
28 #define PTYPE_ERR 0
29 #define PTYPE_HTML 1
30 #define PTYPE_GIF 2
31 #define PTYPE_TEXT 3
32 #define PTYPE_JPEG 4
33 #define PTYPE_FLASH 5
34 #define PTYPE_MPEG 6
35 #define PTYPE_PDF 7
36 #define PTYPE_CGI 8
37 #define PTYPE_PL 9 //pl
38 
39 #ifndef HTTPD_INCLUDE
40 
41 /* HTML Doc. for ERROR */
42 #define ERROR_HTML_PAGE "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n<HTML>\r\n<BODY>\r\nSorry, the page you requested was not found.\r\n</BODY>\r\n</HTML>\r\n\0"
43 //static char ERROR_HTML_PAGE[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n<HTML>\r\n<BODY>\r\nSorry, the page you requested was not found.\r\n</BODY>\r\n</HTML>\r\n\0";
44 
45 #define ERROR_REQUEST_PAGE "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n<HTML>\r\n<BODY>\r\nInvalid request.\r\n</BODY>\r\n</HTML>\r\n\0"
46 //static char ERROR_REQUEST_PAGE[] = "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n<HTML>\r\n<BODY>\r\nInvalid request.\r\n</BODY>\r\n</HTML>\r\n\0";
47 
48 #define RETURN_CGI_PAGE "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 59\r\n\r\n<html><head><title>Nuri - Configuration</title></head><BODY>CGI command was executed.</BODY></HTML>\0"
49 
50 #else
51 
52 /* Response header for HTML*/
53 #define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "
54 //static PROGMEM char RES_HTMLHEAD_OK[] = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: ";
55 /* Response head for TEXT */
56 #define RES_TEXTHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: "
57 
58 /* Response head for GIF */
59 #define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: "
60 
61 /* Response head for JPEG */
62 #define RES_JPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: "
63 
64 /* Response head for FLASH */
65 #define RES_FLASHHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: "
66 //static PROGMEM char RES_FLASHHEAD_OK[] = "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: ";
67 
68 /* Response head for MPEG */
69 #define RES_MPEGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: video/mpeg\r\nContent-Length: "
70 
71 /* Response head for PDF */
72 #define RES_PDFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/pdf\r\nContent-Length: "
73 #endif
74 
75 
76 #define MAX_URI_SIZE 1460//(TX_RX_MAX_BUF_SIZE/2 - sizeof(char)*2)
77 
78 /*
79  @brief Structure of HTTP REQUEST
80  */
81 typedef struct _st_http_request
82 {
83  uint8 METHOD;
84  uint8 TYPE;
85  char URI[ROM_FNAMELEN];
86  char param[MAX_URI_SIZE];
87 }st_http_request;
88 
89 void unescape_http_url(char * url); /* convert escape character to ascii */
90 
91 void parse_http_request(st_http_request *, char *); /* parse request from peer */
92 
93 void find_http_uri_type(uint8 *, char *); /* find MIME type of a file */
94 
95 void make_http_response_head(uint8 *, int8, uint32); /* make response header */
96 
97 unsigned char* get_http_param_value(char* uri, char* param_name); /* get the user-specific parameter value */
98 
99 #endif /* end of __HTTPD_H__ */