00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __AWHANDLER_HTTP__
00024 #define __AWHANDLER_HTTP__
00025
00026 #include "regexmatch.h"
00027
00028 #include "sysnet.h"
00029 #include "monitor.h"
00030 #include "wire.h"
00031
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00173 typedef struct {
00174
00175 aw_event_sig_t
00176 connect,
00177 noconnect,
00178 service,
00179 noservice,
00180 triptime;
00183 u_int32_t
00184 statefull;
00185
00186
00187
00188 } aw_httphandler_cevents_t;
00189
00190
00194 typedef struct {
00195
00196 aw_event_sig_t
00197 match,
00198 nomatch;
00200 } aw_httphandler_revents_t;
00201
00205 typedef enum {
00206
00207 AW_HTTPHANDLER_IDLE,
00208 AW_HTTPHANDLER_WAIT_HEAD_CONNECT,
00209 AW_HTTPHANDLER_WAIT_HEAD_WRITE,
00210 AW_HTTPHANDLER_WAIT_HEAD_READ,
00211 AW_HTTPHANDLER_WAIT_GET_CONNECT,
00212 AW_HTTPHANDLER_WAIT_GET_WRITE,
00213 AW_HTTPHANDLER_WAIT_GET_READ,
00214 AW_HTTPHANDLER_DONE
00216 } aw_httphandler_state_cd_t;
00217
00218
00219 #define AW_HTTPHANDLER_READ_BUFFER_SIZE 4096
00220
00221
00222 #define AW_HTTPHANDLER_LASTMODIFIED_BUFFER_SIZE 64
00223
00224
00228 typedef struct {
00229
00230 aw_httphandler_state_cd_t
00231 state_cd;
00232
00233 int32_t
00234 sfd;
00235
00236 aw_event_t
00237 *current_event;
00238
00239
00240 aw_timestamp_t
00241 starttime;
00242
00243
00244 u_int32_t
00245 nbytes;
00246
00247
00248 int64_t
00249 data_left;
00250
00251 byte_t
00252 read_buffer[AW_HTTPHANDLER_READ_BUFFER_SIZE];
00253
00254 time_t
00255 last_modified;
00256
00257
00258
00259 u_int32_t
00260 *match_markers;
00261
00262
00263 int32_t
00264 connect;
00265
00266
00267 int32_t
00268 service;
00269
00270 } aw_httphandler_state_t;
00271
00272
00276 typedef struct {
00277
00278 aw_httphandler_revents_t
00279 revents;
00280
00281
00282 const byte_t
00283 *regex;
00284
00285
00286 const byte_t
00287 *subst;
00288
00289 } aw_httphandler_regex_t;
00290
00294 typedef struct {
00295
00296 aw_httphandler_revents_t
00297 revents;
00298
00299
00300 regex_t
00301 pattern;
00302
00303
00304 byte_t
00305 *subst;
00306
00307 } aw_httphandler_watcher_t;
00308
00312 typedef struct {
00313
00314 byte_t
00315 *filename;
00316
00317 int32_t
00318 fd;
00319
00320 aw_event_sig_t
00321 updated;
00322
00323 } aw_httphandler_mirror_t;
00324
00325
00329 typedef struct {
00330
00331 aw_handler_t
00332 handler_header;
00333
00334 aw_httphandler_state_t
00335 state;
00336
00337 aw_httphandler_cevents_t
00338 cevents;
00339
00340 struct sockaddr_in
00341 service_addr;
00342
00343
00344 aw_address_t
00345 timeout_event_id;
00346
00347
00348 aw_alarm_sched_t
00349 timeout_sched;
00350
00351 byte_t
00352 *url,
00353 *headreq,
00354 *getreq;
00355
00356 u_int32_t
00357 nwatchers;
00358
00359 aw_httphandler_watcher_t
00360 *watchers;
00361
00362 aw_httphandler_mirror_t
00363 mirror;
00364
00365 } aw_httphandler_t ;
00366
00367
00383 aw_httphandler_t *aw_create_httphandler(const byte_t *url,
00384 const aw_httphandler_cevents_t *cevents,
00385 const aw_timestamp_t timeout,
00386 u_int32_t nregexs,
00387 const aw_httphandler_regex_t *regexs,
00388 const byte_t *mirror_filename,
00389 const aw_event_sig_t *mirror_updated,
00390 int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00391 int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00392 const aw_alarm_sched_t *sched,
00393 aw_logger_t *logger
00394 );
00395
00396
00401 void aw_free_httphandler(aw_httphandler_t *p);
00402
00403
00407 aw_handler_t *aw_wire_httphandler(aw_wire_mkhandler_args_t *args);
00408
00409
00410 #endif
00411