Changeset 969
- Timestamp:
- 12/31/07 21:17:48 (11 months ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/mime.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r960 r969 1 2007-12-31 A.D.F <adefacc@tin.it> 2 3 * mime.c 4 - changed cherokee_mime_load_mime_types() 5 to interpret a sequence of digits preceded by '.' 6 as a max-age value in seconds for that mime type 7 (instead of interpreting it as a file extension); 8 i.e. to set a max-age of 65 seconds in mime.types for html files: 9 10 # mime type [ .number ] extension1 [ extensions ... ] 11 text/html .65 html htm shtml 12 1 13 2007-12-21 A.D.F <adefacc@tin.it> 2 14 cherokee/trunk/cherokee/mime.c
r835 r969 116 116 { 117 117 ret_t ret; 118 cuint_t maxage = 0; 118 119 char *p; 119 120 char *end; … … 176 177 cherokee_mime_entry_set_type (entry, type.buf); 177 178 178 /* Adds its extensions 179 */ 180 p = tmp; 181 while (p < nl) { 179 /* Adds its max-age and file extensions. 180 */ 181 for (p = tmp; p < nl; p = tmp) { 182 182 cherokee_buffer_clean (&ext); 183 183 184 184 /* Look for the next extension 185 185 */ 186 while ((*p == ' ') || (*p == '\t')) p++; 187 if (p >= nl) break; 186 while ((*p == ' ') || (*p == '\t')) 187 p++; 188 if (p >= nl) 189 break; 188 190 189 191 c1 = strchr (p, ' '); … … 191 193 192 194 tmp = cherokee_min_str (c1, c2); 193 if (tmp == NULL) tmp = nl; 194 195 /* Add it to the table 195 if (tmp == NULL) 196 tmp = nl; 197 198 if (*p == '.') { 199 char *p2 = p; 200 201 /* It could be a max-age value. 202 */ 203 for (++p2, len = 0; p2 < tmp; ++p2, ++len) { 204 if (!isdigit(*p2)) 205 break; 206 } 207 /* If it is too short or 208 * it is not made of digits only 209 * then ignore this value. 210 */ 211 if (len < 1 || p2 < tmp) 212 continue; 213 214 /* Convert max-age value. 215 */ 216 if (len > 9) { 217 maxage = (cuint_t) 999999999; 218 } else { 219 maxage = (cuint_t) atoi(p + 1); 220 } 221 222 /* Set max-age value. 223 */ 224 cherokee_mime_entry_set_maxage(entry, maxage); 225 226 TRACE(ENTRIES, "Set max-age %9u, mime type '%s'\n", maxage, type.buf); 227 228 continue; 229 } 230 231 /* Add this file extension to the table. 196 232 */ 197 233 cherokee_buffer_add (&ext, p, tmp-p); 198 234 cherokee_avl_add (&mime->mime_table, &ext, entry); 199 235 200 TRACE(ENTRIES, "Adding mime '%s' -> '%s'\n", ext.buf, type.buf); 201 202 p = tmp; 236 TRACE(ENTRIES, "Added mime '%s' -> '%s'\n", ext.buf, type.buf); 203 237 } 204 238