You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
65 lines
2.2 KiB
10 years ago
|
#ifndef HTTPD_H
|
||
|
#define HTTPD_H
|
||
|
|
||
10 years ago
|
#define HTTPDVER "0.3"
|
||
10 years ago
|
|
||
10 years ago
|
#define HTTPD_CGI_MORE 0
|
||
|
#define HTTPD_CGI_DONE 1
|
||
10 years ago
|
#define HTTPD_CGI_NOTFOUND 2
|
||
10 years ago
|
#define HTTPD_CGI_AUTHENTICATED 3
|
||
10 years ago
|
|
||
10 years ago
|
#define HTTPD_METHOD_GET 1
|
||
|
#define HTTPD_METHOD_POST 2
|
||
10 years ago
|
|
||
10 years ago
|
|
||
10 years ago
|
typedef struct HttpdPriv HttpdPriv;
|
||
|
typedef struct HttpdConnData HttpdConnData;
|
||
10 years ago
|
typedef struct HttpdPostData HttpdPostData;
|
||
10 years ago
|
|
||
|
typedef int (* cgiSendCallback)(HttpdConnData *connData);
|
||
|
|
||
|
//A struct describing a http connection. This gets passed to cgi functions.
|
||
|
struct HttpdConnData {
|
||
|
struct espconn *conn;
|
||
10 years ago
|
char requestType;
|
||
10 years ago
|
char *url;
|
||
|
char *getArgs;
|
||
|
const void *cgiArg;
|
||
|
void *cgiData;
|
||
10 years ago
|
void *cgiPrivData; // Used for streaming handlers storing state between requests
|
||
10 years ago
|
HttpdPriv *priv;
|
||
|
cgiSendCallback cgi;
|
||
10 years ago
|
HttpdPostData *post;
|
||
|
};
|
||
|
|
||
|
//A struct describing the POST data sent inside the http connection. This is used by the CGI functions
|
||
|
struct HttpdPostData {
|
||
|
int len; // POST Content-Length
|
||
|
int buffSize; // The maximum length of the post buffer
|
||
|
int buffLen; // The amount of bytes in the current post buffer
|
||
|
int received; // The total amount of bytes received so far
|
||
|
char *buff; // Actual POST data buffer
|
||
|
char *multipartBoundary;
|
||
10 years ago
|
};
|
||
|
|
||
10 years ago
|
//A struct describing an url. This is the main struct that's used to send different URL requests to
|
||
|
//different routines.
|
||
10 years ago
|
typedef struct {
|
||
|
const char *url;
|
||
|
cgiSendCallback cgiCb;
|
||
|
const void *cgiArg;
|
||
|
} HttpdBuiltInUrl;
|
||
|
|
||
10 years ago
|
int ICACHE_FLASH_ATTR cgiRedirect(HttpdConnData *connData);
|
||
10 years ago
|
void ICACHE_FLASH_ATTR httpdRedirect(HttpdConnData *conn, char *newUrl);
|
||
|
int httpdUrlDecode(char *val, int valLen, char *ret, int retLen);
|
||
|
int ICACHE_FLASH_ATTR httpdFindArg(char *line, char *arg, char *buff, int buffLen);
|
||
10 years ago
|
void ICACHE_FLASH_ATTR httpdInit(HttpdBuiltInUrl *fixedUrls, int port);
|
||
|
const char *httpdGetMimetype(char *url);
|
||
|
void ICACHE_FLASH_ATTR httpdStartResponse(HttpdConnData *conn, int code);
|
||
|
void ICACHE_FLASH_ATTR httpdHeader(HttpdConnData *conn, const char *field, const char *val);
|
||
|
void ICACHE_FLASH_ATTR httpdEndHeaders(HttpdConnData *conn);
|
||
10 years ago
|
int ICACHE_FLASH_ATTR httpdGetHeader(HttpdConnData *conn, char *header, char *ret, int retLen);
|
||
10 years ago
|
int ICACHE_FLASH_ATTR httpdSend(HttpdConnData *conn, const char *data, int len);
|
||
10 years ago
|
|
||
|
#endif
|