Changeset 1880
- Timestamp:
- 08/20/08 14:58:47 (3 months ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/admin/PageEntry.py (modified) (3 diffs)
- cherokee/trunk/admin/consts.py (modified) (1 diff)
- cherokee/trunk/cherokee/config_entry.c (modified) (3 diffs)
- cherokee/trunk/cherokee/config_entry.h (modified) (2 diffs)
- cherokee/trunk/cherokee/connection-protected.h (modified) (1 diff)
- cherokee/trunk/cherokee/connection.c (modified) (6 diffs)
- cherokee/trunk/cherokee/rule_list.c (modified) (3 diffs)
- cherokee/trunk/cherokee/virtual_server.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r1878 r1880 1 1 2008-08-20 Alvaro Lopez Ortega <alvaro@alobbs.com> 2 3 * cherokee/rule_list.c, cherokee/virtual_server.c, 4 cherokee/connection-protected.h, cherokee/config_entry.c, 5 cherokee/config_entry.h, cherokee/connection.c, 6 admin/PageEntry.py, admin/consts.py: Adds support por expiration 7 headers. This patch adds support to both the server and the 8 configuration interface. 2 9 3 10 * cherokee/config_node.c (cherokee_config_node_read_long), cherokee/trunk/admin/PageEntry.py
r1752 r1880 11 11 DEFAULT_RULE_WARNING = 'The default match ought not to be changed.' 12 12 13 NOTE_DOCUMENT_ROOT = 'Allows to specify an alternative document root path.' 14 NOTE_HANDLER = 'How the connection will be handled.' 15 NOTE_HTTPS_ONLY = 'Enable to allow access to the resource only by https.' 16 NOTE_ALLOW_FROM = 'List of IPs and subnets allowed to access the resource.' 17 NOTE_VALIDATOR = 'Which, if any, will be the authentication method.' 13 NOTE_DOCUMENT_ROOT = 'Allows to specify an alternative document root path.' 14 NOTE_HANDLER = 'How the connection will be handled.' 15 NOTE_HTTPS_ONLY = 'Enable to allow access to the resource only by https.' 16 NOTE_ALLOW_FROM = 'List of IPs and subnets allowed to access the resource.' 17 NOTE_VALIDATOR = 'Which, if any, will be the authentication method.' 18 NOTE_EXPIRATION = 'Points how long the files should be cached' 19 NOTE_EXPIRATION_TIME = 'How long from the object can be cached' 18 20 19 21 DATA_VALIDATION = [ … … 129 131 tabs += [('Handler', str(table))] 130 132 133 # Expiration 134 tabs += [('Expiration', self._render_expiration())] 135 131 136 # Security 132 137 tabs += [('Security', self._render_security())] … … 158 163 return str(table) + e 159 164 165 def _render_expiration (self): 166 txt = '' 167 pre = "%s!expiration"%(self._conf_prefix) 168 169 table = TableProps() 170 self.AddPropOptions_Ajax (table, "Expiration", pre, EXPIRATION_TYPE, NOTE_EXPIRATION) 171 172 exp = self._cfg.get_val(pre) 173 if exp == 'time': 174 self.AddPropEntry (table, 'Time to expire', '%s!time'%(pre), NOTE_EXPIRATION_TIME) 175 176 txt += str(table) 177 return txt 178 160 179 def _render_security (self): 161 180 pre = self._conf_prefix cherokee/trunk/admin/consts.py
r1736 r1880 108 108 ('geoip', 'GeoIP') 109 109 ] 110 111 EXPIRATION_TYPE = [ 112 ('', 'Not set'), 113 ('epoch', 'Already expired on 1970'), 114 ('max', 'Do not expire until 2038'), 115 ('time', 'Custom value') 116 ] cherokee/trunk/cherokee/config_entry.c
r1375 r1880 62 62 entry->document_root = NULL; 63 63 entry->users = NULL; 64 65 entry->expiration = cherokee_expiration_none; 66 entry->expiration_time = 0; 64 67 65 68 return ret_ok; … … 160 163 entry->users = source->users; 161 164 165 if ((entry->expiration == cherokee_expiration_none) && 166 (source->expiration != cherokee_expiration_none)) 167 { 168 entry->expiration = source->expiration; 169 entry->expiration_time = source->expiration_time; 170 } 171 162 172 return ret_ok; 163 173 } … … 177 187 printf ("auth_realm: %s\n", entry->auth_realm ? entry->auth_realm->buf : ""); 178 188 printf ("users: %p\n", entry->users); 189 printf ("expiration type: %d\n", entry->expiration); 190 printf ("expiration_time %lu\n", entry->expiration_time); 179 191 180 192 return ret_ok; cherokee/trunk/cherokee/config_entry.h
r1430 r1880 38 38 #define CHEROKEE_CONFIG_PRIORITY_DEFAULT 1 39 39 40 typedef enum { 41 cherokee_expiration_none, 42 cherokee_expiration_epoch, 43 cherokee_expiration_max, 44 cherokee_expiration_time 45 } cherokee_expiration_t; 40 46 41 47 typedef struct { … … 60 66 cherokee_http_auth_t authentication; 61 67 cherokee_avl_t *users; 68 69 /* Headers 70 */ 71 cherokee_expiration_t expiration; 72 time_t expiration_time; 62 73 } cherokee_config_entry_t; 63 74 cherokee/trunk/cherokee/connection-protected.h
r1871 r1880 186 186 int regex_ovector[OVECTOR_LEN]; 187 187 int regex_ovecsize; 188 189 cherokee_expiration_t expiration; 190 time_t expiration_time; 188 191 }; 189 192 cherokee/trunk/cherokee/connection.c
r1871 r1880 79 79 #include "header-protected.h" 80 80 #include "iocache.h" 81 #include "dtm.h" 81 82 82 83 #define ENTRIES "core,connection" … … 119 120 n->polling_multiple = false; 120 121 n->polling_mode = FDPOLL_MODE_NONE; 122 n->expiration = cherokee_expiration_none; 123 n->expiration_time = 0; 121 124 122 125 cherokee_buffer_init (&n->buffer); … … 247 250 conn->polling_multiple = false; 248 251 conn->polling_mode = FDPOLL_MODE_NONE; 252 conn->expiration = cherokee_expiration_none; 253 conn->expiration_time = 0; 249 254 250 255 memset (conn->regex_ovector, OVECTOR_LEN * sizeof(int), 0); … … 409 414 410 415 static void 411 build_response_header_ _authenticate(cherokee_connection_t *conn, cherokee_buffer_t *buffer)416 build_response_header_authentication (cherokee_connection_t *conn, cherokee_buffer_t *buffer) 412 417 { 413 418 /* Basic Authenticatiom … … 452 457 453 458 static void 459 build_response_header_expiration (cherokee_connection_t *conn, cherokee_buffer_t *buffer) 460 { 461 time_t exp_time; 462 struct tm exp_tm; 463 size_t szlen = 0; 464 char bufstr[DTM_SIZE_GMTTM_STR + 2]; 465 466 switch (conn->expiration) { 467 case cherokee_expiration_epoch: 468 cherokee_buffer_add_str (buffer, "Expires: Tue, 01 Jan 1970 00:00:01 GMT" CRLF); 469 cherokee_buffer_add_str (buffer, "Cache-Control: no-cache" CRLF); 470 break; 471 case cherokee_expiration_max: 472 cherokee_buffer_add_str (buffer, "Expires: Thu, 31 Dec 2037 23:55:55 GMT" CRLF); 473 cherokee_buffer_add_str (buffer, "Cache-Control: max-age=315360000" CRLF); 474 break; 475 case cherokee_expiration_time: 476 exp_time = (cherokee_bogonow_now + conn->expiration_time); 477 cherokee_gmtime (&exp_time, &exp_tm); 478 szlen = cherokee_dtm_gmttm2str (bufstr, sizeof(bufstr), &exp_tm); 479 480 cherokee_buffer_add_str (buffer, "Expires: "); 481 cherokee_buffer_add (buffer, bufstr, szlen); 482 cherokee_buffer_add_str (buffer, CRLF); 483 484 cherokee_buffer_add_str (buffer, "Cache-Contro: max-age="); 485 cherokee_buffer_add_long10 (buffer, conn->expiration_time); 486 cherokee_buffer_add_str (buffer, CRLF); 487 break; 488 default: 489 SHOULDNT_HAPPEN; 490 } 491 } 492 493 494 static void 454 495 build_response_header (cherokee_connection_t *conn, cherokee_buffer_t *buffer) 455 496 { … … 510 551 */ 511 552 if ((conn->realm_ref != NULL) && (conn->error_code == http_unauthorized)) { 512 build_response_header__authenticate (conn, buffer); 553 build_response_header_authentication (conn, buffer); 554 } 555 556 /* Expiration 557 */ 558 if (conn->expiration != cherokee_expiration_none) { 559 build_response_header_expiration (conn, buffer); 513 560 } 514 561 cherokee/trunk/cherokee/rule_list.c
r1398 r1880 61 61 } 62 62 63 static void 64 update_connection (cherokee_connection_t *conn, 65 cherokee_config_entry_t *ret_config) 66 { 67 if (! conn->realm_ref) 68 conn->realm_ref = ret_config->auth_realm; 69 if (! conn->auth_type) 70 conn->auth_type = ret_config->authentication; 71 72 if ((conn->expiration == cherokee_expiration_none) && 73 (ret_config->expiration != cherokee_expiration_none)) 74 { 75 conn->expiration = ret_config->expiration; 76 conn->expiration_time = ret_config->expiration_time; 77 } 78 } 63 79 64 80 ret_t … … 95 111 cherokee_config_entry_complete (ret_config, &rule->config); 96 112 97 /* TODO: FIX this..113 /* Update the connection 98 114 */ 99 if (! conn->realm_ref) 100 conn->realm_ref = ret_config->auth_realm; 101 if (! conn->auth_type) 102 conn->auth_type = ret_config->authentication; 115 update_connection (conn, ret_config); 103 116 104 117 /* Should it continue? */ … … 114 127 list->def_rule->match(list->def_rule, conn); 115 128 cherokee_config_entry_complete (ret_config, &list->def_rule->config); 129 130 /* Update the connection 131 */ 132 update_connection (conn, ret_config); 116 133 117 /* TODO: FIX this..118 */119 if (! conn->realm_ref)120 conn->realm_ref = ret_config->auth_realm;121 if (! conn->auth_type)122 conn->auth_type = ret_config->authentication;123 124 134 return ret_ok; 125 135 } cherokee/trunk/cherokee/virtual_server.c
r1715 r1880 457 457 entry->only_secure = !! atoi(conf->val.buf); 458 458 459 } else if (equal_buf_str (&conf->key, "expiration")) { 460 if (equal_buf_str (&conf->val, "none")) { 461 entry->expiration = cherokee_expiration_none; 462 463 } else if (equal_buf_str (&conf->val, "epoch")) { 464 entry->expiration = cherokee_expiration_epoch; 465 466 } else if (equal_buf_str (&conf->val, "max")) { 467 entry->expiration = cherokee_expiration_max; 468 469 } else if (equal_buf_str (&conf->val, "time")) { 470 entry->expiration = cherokee_expiration_time; 471 ret = cherokee_config_node_read_long (conf, "time", &entry->expiration_time); 472 if (ret != ret_ok) { 473 PRINT_ERROR_S ("Expiration 'time' without a time property\n"); 474 return ret_error; 475 } 476 } 477 459 478 } else if (equal_buf_str (&conf->key, "match")) { 460 479 /* Ignore: Previously handled