00001
00002
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 #ifndef __HTTP_H__
00038 #define __HTTP_H__
00039
00040 #include "global.h"
00041
00042 namespace tacpp {
00043
00044
00045 #define HTTP_DIR "http"
00046
00047 #define HTTP_TIMEOUT 2
00048
00049 #define INVALID_AUTH_FILE "/invalid_auth.html"
00050 #define INVALID_FILE "/invalid_file.html"
00051
00052
00053 #define HTTP_ADMIN_DIR 1
00054 #define HTTP_USER_DIR 2
00055
00056
00057 #define MAX_FORM_FIELDS 20
00058
00064 class HttpHeaderData {
00065 public:
00068 HttpHeaderData();
00069 #define HTTP_METHOD_LEN 20
00070
00072 char method[HTTP_METHOD_LEN];
00073 #define HTTP_REQUEST_LEN 100
00074
00076 char request[HTTP_REQUEST_LEN];
00077 #define USER_AGENT_LEN 80
00078
00080 char User_Agent[USER_AGENT_LEN];
00081 #define HTTP_HOST_LEN 30
00082
00084 char Host[HTTP_HOST_LEN];
00085 #define ACCEPT_LEN 300
00086
00088 char Accept[ACCEPT_LEN];
00091 #define ACCEPT_ENC_LEN 10
00092 char Accept_Encoding[ACCEPT_ENC_LEN];
00095 #define ACCEPT_LAN_LEN 10
00096 char Accept_Language[ACCEPT_LAN_LEN];
00099 #define ACCEPT_CHR_LEN 20
00100 char Accept_Charset[ACCEPT_CHR_LEN];
00103 #define VIA_LEN 80
00104 char Via[VIA_LEN];
00107 #define X_FORW_LEN 30
00108 char X_Forwarded_For[X_FORW_LEN];
00111 #define CACHE_CONT_LEN 20
00112 char Cache_Control[CACHE_CONT_LEN];
00115 #define CONNECTION_LEN 30
00116 char Connection[CONNECTION_LEN];
00119 #define AUTHOR_LEN 30
00120 char Authorization[AUTHOR_LEN];
00123 #define HTTP_USERNAME_LEN 50
00124 char username[HTTP_USERNAME_LEN];
00127 #define HTTP_PASSWORD_LEN 50
00128 char password[HTTP_PASSWORD_LEN];
00129 #define HTTP_DATA_LEN 200
00130
00132 char data_string[HTTP_DATA_LEN];
00135 string Cookie;
00136 };
00137
00143 class HttpPacket : public Packet {
00144 public:
00147 int fid;
00150 HttpPacket(int,struct in_addr);
00153 string hread();
00156 bool hwrite(string);
00157 };
00158
00164 class HttpHeader : public HttpPacket {
00167 string http_date();
00168 public:
00171 HttpHeader(int fh,struct in_addr addr) : HttpPacket(fh, addr) {}
00174 HttpHeaderData *get_request();
00177 void header_html();
00180 void header_gif();
00183 void header_jpg();
00186 void header_auth();
00189 void header_perl();
00192 void header_class();
00195 void header_css();
00198 void header_js();
00201 void send_stop();
00202 };
00203
00209 struct formsdata {
00210 char *varname;
00211 char *data;
00212 };
00213
00219 class HttpFile : public HttpHeader {
00222 std::ifstream htmlf;
00225 bool openfile(char*);
00228 void readwrite();
00231 void closefile();
00234 void send_file_from_file(char*);
00237 void run_perl_file(char*,HttpHeaderData*);
00238 public:
00241 int dir;
00244 HttpFile(int,struct in_addr);
00247 void send_file(char*,HttpHeaderData*);
00250 void send_file_only(char*);
00253 void send_authen();
00256 void send_nofile();
00257 };
00258
00264 class HttpServer : public HttpFile {
00267 char address[30];
00268 public:
00271 HttpServer(int,struct in_addr);
00274 bool authentication(char*,char*,char*,char*);
00277 void process();
00278 };
00279
00280 };
00281
00282 #endif //__HTTP_H__