Go to the documentation of this file.00001 #ifndef _PRO_UHTTP_UHTTP_H_
00002 #define _PRO_UHTTP_UHTTP_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00045 #include <cfg/http.h>
00046
00047 #include <pro/uhttp/compiler.h>
00048 #include <pro/uhttp/streamio.h>
00049
00050 #if !defined(HTTPD_EXCLUDE_DATE)
00051 #include <time.h>
00052 #endif
00053
00080
00081 #if 0
00082
00083 #define HTTP_VERSION 0x09
00084 #undef HTTP_MAJOR_VERSION
00085 #define HTTP_MAJOR_VERSION 0
00086 #undef HTTP_MINOR_VERSION
00087 #define HTTP_MINOR_VERSION 9
00088 #endif
00089
00090 #ifndef HTTP_MAJOR_VERSION
00091 #define HTTP_MAJOR_VERSION 1
00092 #endif
00093
00094 #ifndef HTTP_MINOR_VERSION
00095 #define HTTP_MINOR_VERSION 1
00096 #endif
00097
00098 #ifndef HTTP_VERSION
00099 #if HTTP_MAJOR_VERSION == 0
00100 #if HTTP_MINOR_VERSION == 9
00101 #define HTTP_VERSION 0x09
00102 #endif
00103 #elif HTTP_MAJOR_VERSION == 1
00104 #if HTTP_MINOR_VERSION == 0
00105 #define HTTP_VERSION 0x10
00106 #elif HTTP_MINOR_VERSION == 1
00107 #define HTTP_VERSION 0x11
00108 #endif
00109 #endif
00110 #endif
00111
00112 #ifndef HTTP_VERSION
00113 #error Cannot determine HTTP version
00114 #endif
00115
00119 #define HTTP_METHOD_GET 1
00120
00121 #define HTTP_METHOD_POST 2
00122
00123 #define HTTP_METHOD_HEAD 3
00124
00129 #define HTTP_CONN_CLOSE 1
00130
00131 #define HTTP_CONN_KEEP_ALIVE 2
00132
00135 typedef struct _HTTP_REQUEST HTTP_REQUEST;
00136
00138 struct _HTTP_REQUEST {
00139 int req_method;
00140 char *req_url;
00141 int req_version;
00142 char *req_query;
00143 char *req_argp;
00144 char *req_argn;
00145 char *req_argv;
00146 int req_connection;
00147 #if HTTP_VERSION >= 0x10
00148 long req_length;
00149 char *req_realm;
00150 char *req_type;
00151 char *req_cookie;
00152 char *req_auth;
00153 char *req_agent;
00154 #if !defined(HTTPD_EXCLUDE_DATE)
00155 time_t req_ims;
00156 #endif
00157 char *req_referer;
00158 char *req_host;
00159 char *req_encoding;
00160 char *req_bnd_dispo;
00161 char *req_bnd_type;
00162 #endif
00163 };
00164
00166 typedef struct _HTTPD_SESSION HTTPD_SESSION;
00167
00169 struct _HTTPD_SESSION {
00170 HTTP_STREAM *s_stream;
00171 HTTP_REQUEST s_req;
00172 };
00173
00176 extern const char ct_GET[];
00177 extern const char ct_HEAD[];
00178 extern const char ct_POST[];
00179 extern const char ct_Content_Disposition[];
00180 extern const char ct_Content_Type[];
00181 extern const char ct_Accept_Encoding[];
00182 extern const char ct_Authorization[];
00183 extern const char ct_Connection[];
00184 extern const char ct_close[];
00185 extern const char ct_Keep_Alive[];
00186 extern const char ct_Content_Length[];
00187 extern const char ct_Cookie[];
00188 extern const char ct_Host[];
00189 extern const char ct_Referer[];
00190 extern const char ct_User_Agent[];
00191 extern const char ct_Content_Encoding[];
00192 extern const char ct_Location[];
00193
00194 #if !defined(HTTPD_EXCLUDE_DATE)
00195 extern const char ct_If_Modified_Since[];
00196 extern const char ct_Last_Modified[];
00197 extern const char ct_Expires[];
00198 extern const char ct_Date[];
00199 #endif
00200
00202 extern char *http_root;
00203 #define HTTP_ROOT (http_root ? http_root : HTTP_DEFAULT_ROOT)
00204
00206 typedef int (*HTTP_AUTH_VALIDATOR) (HTTPD_SESSION*);
00208 extern HTTP_AUTH_VALIDATOR httpd_auth_validator;
00209
00211 typedef int (*HTTP_LOC_REDIRECTOR) (HTTPD_SESSION*);
00213 extern HTTP_LOC_REDIRECTOR httpd_loc_redirector;
00214
00215
00227 extern int HttpRegisterRootPath(char *path);
00228
00234 extern int HttpParseHeader(HTTPD_SESSION *hs);
00235
00241 extern int HttpParseMultipartHeader(HTTPD_SESSION *hs, const char *bnd, long *avail);
00242
00248 extern void HttpSendHeaderTop(HTTPD_SESSION *hs, int status);
00249 #if !defined(HTTPD_EXCLUDE_DATE)
00250
00256 extern void HttpSendHeaderDate(HTTPD_SESSION *hs, time_t mtime);
00257 #endif
00258
00264 extern void HttpSendHeaderBottom(HTTPD_SESSION *hs, char *type, char *subtype, long bytes);
00265
00271 extern void HttpSendError(HTTPD_SESSION *hs, int status);
00272
00278 extern int HttpSendRedirection(HTTPD_SESSION *hs, int code, ...);
00279
00289 extern char *HttpArgParseFirst(HTTP_REQUEST * req);
00290
00296 extern char *HttpArgParseNext(HTTP_REQUEST * req);
00297
00313 extern char *HttpArgReadNext(HTTPD_SESSION *hs, long *avail);
00314
00327 extern char *HttpArgValue(HTTP_REQUEST * req);
00328
00347 extern const char *HttpArgValueSub(const char *str, const char *name, int *len);
00348
00354 void HttpdClientHandler(HTTP_STREAM *sp);
00355
00363
00365 #endif