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 #ifndef _StatPages_h_
00032 #define _StatPages_h_
00033 #include "P_EventSystem.h"
00034
00035 #include "HTTP.h"
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #define STAT_PAGE_SUCCESS STAT_PAGES_EVENTS_START+0
00063 #define STAT_PAGE_FAILURE STAT_PAGES_EVENTS_START+1
00064
00065 typedef Action *(*StatPagesFunc) (Continuation * cont, HTTPHdr * header);
00066
00067 struct StatPageData
00068 {
00069 char *data;
00070 char *type;
00071 int length;
00072
00073 StatPageData():data(NULL), type(NULL), length(0)
00074 {
00075 }
00076 StatPageData(char *adata):data(adata), type(NULL)
00077 {
00078 length = strlen(adata);
00079 }
00080 StatPageData(char *adata, int alength):data(adata), type(NULL), length(alength)
00081 {
00082 }
00083 };
00084
00085 struct StatPagesManager
00086 {
00087 void init();
00088
00089 inkcoreapi void register_http(const char *hostname, StatPagesFunc func);
00090
00091
00092 Action *handle_http(Continuation * cont, HTTPHdr * header);
00093 bool is_stat_page(URL * url);
00094 bool is_cache_inspector_page(URL * url);
00095 int m_enabled;
00096 };
00097
00098 inkcoreapi extern StatPagesManager statPagesManager;
00099
00100
00101
00102 class BaseStatPagesHandler:public Continuation
00103 {
00104 public:
00105 BaseStatPagesHandler(ProxyMutex * amutex):Continuation(amutex), response(NULL), response_size(0), response_length(0)
00106 {
00107 };
00108 ~BaseStatPagesHandler() {
00109 resp_clear();
00110 };
00111
00112 protected:
00113
00114 inkcoreapi void resp_clear(void);
00115 inkcoreapi void resp_add(const char *fmt, ...);
00116 inkcoreapi void resp_add_sep(void);
00117 inkcoreapi void resp_begin(const char *title);
00118 inkcoreapi void resp_end(void);
00119 void resp_begin_numbered(void);
00120 void resp_end_numbered(void);
00121 inkcoreapi void resp_begin_unnumbered(void);
00122 inkcoreapi void resp_end_unnumbered(void);
00123 inkcoreapi void resp_begin_item(void);
00124 void resp_end_item(void);
00125 inkcoreapi void resp_begin_table(int border, int columns, int percent);
00126 inkcoreapi void resp_end_table();
00127 inkcoreapi void resp_begin_row();
00128 inkcoreapi void resp_end_row();
00129 inkcoreapi void resp_begin_column(int percent = -1, const char *align = NULL);
00130 inkcoreapi void resp_end_column();
00131
00132 char *response;
00133 int response_size;
00134 int response_length;
00135 };
00136
00137 #endif