X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fhttp.h;h=9fe4c3818d4bda4bf5fe8d1486b409c24bf1053c;hb=024bf80e5f29e4de00d0813d23a4d3b67245ead7;hp=e280bbaa546b6fd3f5c68bed7dbb0f30ea6915ce;hpb=aa23c5d7c7b2b79e8ff74eb00bb12531b35731b4;p=bertos.git diff --git a/bertos/net/http.h b/bertos/net/http.h index e280bbaa..9fe4c381 100644 --- a/bertos/net/http.h +++ b/bertos/net/http.h @@ -43,25 +43,38 @@ #ifndef NET_HTTP_H #define NET_HTTP_H - -#include - -#include -#include -#include #include -#include -typedef int (*http_gci_handler_t)(struct netconn *client, char *revc_buf, size_t revc_len); +typedef int (*http_handler_t)(struct netconn *client, const char *name, char *revc_buf, size_t revc_len); typedef struct HttpCGI { - const char *name; - http_gci_handler_t handler; + unsigned type; ///< Strategy to find string in the cgi table. + const char *name; ///< Request string from GET request + http_handler_t handler; ///< Callback to process the special request } HttpCGI; +#define CGI_MATCH_NONE 0 +#define CGI_MATCH_WORD 1 ///< Select item in table only if string match +#define CGI_MATCH_EXT 2 ///< Select item in table if the extention match +#define CGI_MATCH_NAME 3 ///< Select item in table if the string is content + +#define HTTP_MAX_GET_TOKENS 5 + +int http_getValue(char *tolenized_buf, size_t tolenized_buf_len, const char *key, char *value, size_t len); +int http_tokenizeGetRequest(char *raw_buf, size_t raw_len); +void http_getPageName(const char *recv_buf, size_t recv_len, char *page_name, size_t len); +void http_decodeUri(const char *raw_buf, size_t raw_len, char *decodec_buf, size_t len); + void http_sendOk(struct netconn *client); void http_sendFileNotFound(struct netconn *client); -void http_server(struct netconn *server, struct HttpCGI *gci); +void http_sendInternalErr(struct netconn *client); + +void http_poll(struct netconn *server); +void http_init(http_handler_t default_callback, struct HttpCGI *table); + +int http_testSetup(void); +int http_testRun(void); +int http_testTearDown(void); #endif /* NET_HTTP_H */