http.h
Go to the documentation of this file.
00001
00043 #ifndef NET_HTTP_H
00044 #define NET_HTTP_H
00045 
00046 #include <lwip/tcpip.h>
00047 #include <lwip/api.h>
00048
00049 typedef int (*http_handler_t)(struct netconn *client, const char *name, char *revc_buf, size_t revc_len);
00050
00051 typedef struct HttpCGI
00052 {
00053     unsigned type;
00054     const char *name;
00055     http_handler_t handler;
00056 } HttpCGI;
00057
00058 enum
00059 {
00060     HTTP_CONTENT_JSON = 0,
00061     HTTP_CONTENT_HTML,
00062     HTTP_CONTENT_CSS,
00063     HTTP_CONTENT_JS,
00064     HTTP_CONTENT_PNG,
00065     HTTP_CONTENT_JPEG,
00066     HTTP_CONTENT_GIF,
00067     HTTP_CONTENT_PLAIN,
00068
00069     HTTP_CONTENT_CNT
00070 };
00071
00072 #define CGI_MATCH_NONE   0
00073 #define CGI_MATCH_WORD   1  ///< Select item in table only if string match
00074 #define CGI_MATCH_EXT    2  ///< Select item in table if the extention match
00075 #define CGI_MATCH_NAME   3  ///< Select item in table if the string is content
00076 
00077 int http_getValue(char *tolenized_buf, size_t tolenized_buf_len, const char *key, char *value, size_t len);
00078 int http_tokenizeGetRequest(char *raw_buf, size_t raw_len);
00079 void http_getPageName(const char *recv_buf, size_t recv_len, char *page_name, size_t len);
00080 size_t http_decodeUrl(const char *raw_buf, size_t raw_len, char *decodec_buf, size_t len);
00081 int http_searchContentType(const char *name);
00082
00083 void http_sendOk(struct netconn *client, int content_type);
00084 void http_sendFileNotFound(struct netconn *client, int content_type);
00085 void http_sendInternalErr(struct netconn *client, int content_type);
00086
00087 void http_poll(struct netconn *server);
00088 void http_init(http_handler_t default_callback, struct HttpCGI *table);
00089
00090 int http_testSetup(void);
00091 int http_testRun(void);
00092 int http_testTearDown(void);
00093
00094 #endif /* NET_HTTP_H */