Go to the documentation of this file.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 #include "xmlrpc.h"
00038
00039
00040
00041
00042
00043
00044 #ifndef USE_HTTPAPI
00045 #include "sockets.h"
00046 #endif
00047
00048
00049 enum HTTP_COMMAND {
00050 HTTP_UNKNOWN=-1,
00051 HTTP_GET, HTTP_POST
00052 };
00053
00054 struct HttpRequest
00055 {
00056 HTTP_COMMAND _command;
00057 string _data;
00058
00059 #ifdef USE_HTTPAPI
00060 ULONGLONG _id;
00061 #endif
00062 };
00063
00064 struct HttpServer
00065 {
00066 HttpServer();
00067 ~HttpServer();
00068
00069 void enable_extensions(bool flag=true)
00070 {
00071 _extensions = flag;
00072 }
00073
00074 void register_url(const char* prefix);
00075 void unregister_url(const char* prefix);
00076
00077 void receive_request(HttpRequest& request);
00078
00079 void send_response(HttpRequest& request, const string& str, const char* content_type);
00080 void send_error(HttpRequest& request, u_short code, const char* status_text);
00081
00082 void send(u_short code, const char* status_text, const string& data, const char* content_type, bool connection_close);
00083
00084 protected:
00085 #ifdef USE_HTTPAPI
00086 HANDLE _request;
00087 #else
00088 #ifdef _WIN32
00089 WinSockInit _ws_init;
00090 #endif
00091
00092 AddressList _addr;
00093 Socket _listen_socket;
00094 string _url_prefix;
00095
00096
00097 Socket _conn_socket;
00098 #endif
00099
00100 bool _extensions;
00101
00102 private:
00103 bool handle_request(HttpRequest& request);
00104 };