1999-07-15
1999-07-15 16:59:28 by David Hedbor <david@hedbor.org>
-
41b77cdbf2165783baf8b81ba254c4a6942ddfd2
(96 lines)
(+41/-55)
[
Show
| Annotate
]
Branch: 5.2
Performance tweaking: Added supports caching, rewrote request parsing, fixed HTTP/0.9 support and more
Rev: server/base_server/configuration.pike:1.204
Rev: server/base_server/roxen.pike:1.306
Rev: server/base_server/roxenlib.pike:1.108
Rev: server/etc/include/config.h:1.15
Rev: server/modules/filesystems/filesystem.pike:1.56
Rev: server/modules/misc/contenttypes.pike:1.13
Rev: server/protocols/http.pike:1.142
1:
- string cvs_version = "$Id: configuration.pike,v 1.203 1999/07/02 20:50:03 neotron Exp $";
+ string cvs_version = "$Id: configuration.pike,v 1.204 1999/07/15 16:59:27 neotron Exp $";
#include <module.h>
#include <roxen.h>
357:
pri[i] && pri[i]->stop && pri[i]->stop());
}
- public string type_from_filename( string file, int|void to )
+ public string type_from_filename( string file, int|void to, string|void myext )
{
mixed tmp;
- string ext=extension(file);
-
+
if(!types_fun)
return to?({ "application/octet-stream", 0 }):"application/octet-stream";
-
+ string ext=myext || extension(file);
+
+
// while(file[-1] == '/')
// file = file[0..strlen(file)-2]; // Security patch?
1250:
mixed tmp, tmp2;
mapping|object fid;
-
+
if(!no_magic)
{
#ifndef NO_INTERNAL_HACK
-
+ string type;
// No, this is not beautiful... :)
-
- if(sizeof(file) && (file[0] == '/') &&
- sscanf(file, "%*s/internal-%s", loc))
+ // min length == 17 (/internal-roxen-?..)
+ // This will save some time indeed.
+ if(sizeof(file) > 17 && (file[0] == '/') &&
+ sscanf(file, "%*s/internal-%s-%[^/]", type, loc) == 3)
{
- if(sscanf(loc, "gopher-%[^/]", loc)) // The directory icons.
- {
+ switch(type) {
+ case "gopher":
TRACE_LEAVE(LOCALE->magic_internal_gopher());
return internal_gopher_image(loc);
- }
- if(sscanf(loc, "spinner-%[^/]", loc) // Configuration interface images.
- ||sscanf(loc, "roxen-%[^/]", loc)) // Try /internal-roxen-power
- {
+
+ case "spinner": case "roxen":
TRACE_LEAVE(LOCALE->magic_internal_roxen());
return internal_roxen_image(loc);
}
1309: Inside #if defined(MODULE_LEVEL_SECURITY)
TRACE_LEAVE(LOCALE->request_denied());
return tmp2;
}
- if(find_internal)
+
#endif
-
+ if(find_internal)
{
TRACE_ENTER(LOCALE->calling_find_internal(), find_internal);
LOCK(find_internal);
1402:
}
#endif
#ifdef EXTENSION_MODULES
- if(tmp=extension_modules(loc=extension(file), id))
+ if(tmp=extension_modules(loc = extension(file, id), id))
{
foreach(tmp, funp)
{
1436: Inside #if defined(EXTENSION_MODULES)
}
}
#endif
-
+
foreach(location_modules(id), tmp)
{
loc = tmp[0];
1498:
}
} else
TRACE_LEAVE("");
- } else if(strlen(loc)-1==strlen(file)) {
+ } else if(strlen(loc)-1==strlen(file) && file+"/" == loc) {
// This one is here to allow accesses to /local, even if
// the mountpoint is /local/. It will slow things down, but...
- if(file+"/" == loc)
- {
+
TRACE_ENTER(LOCALE->automatic_redirect_to_location(), tmp[1]);
TRACE_LEAVE(LOCALE->returning_data());
1517:
}
}
}
- }
+
if(fid == -1)
{
1546:
}
// Map the file extensions, but only if there is a file...
- if(objectp(fid)&&
- (tmp=file_extension_modules(loc=extension(id->not_query), id)))
+ if(objectp(fid) &&
+ (tmp = file_extension_modules(loc = extension(id->not_query, id), id))) {
foreach(tmp, funp)
{
TRACE_ENTER(LOCALE->extension_module(loc), funp);
1584:
} else
TRACE_LEAVE("");
}
-
+ }
if(objectp(fid))
{
- if(stringp(id->extension))
+ if(stringp(id->extension)) {
id->not_query += id->extension;
-
-
+ loc = extension(id->not_query, id);
+ }
TRACE_ENTER(LOCALE->content_type_module(), types_module);
- tmp=type_from_filename(id->not_query, 1);
+ tmp=type_from_filename(id->not_query, 1, loc);
TRACE_LEAVE(tmp?LOCALE->returned_mime_type(tmp[0],tmp[1]):
LOCALE->missing_type());
if(tmp)
1621: Inside #if defined(REQUEST_DEBUG)
#ifdef REQUEST_DEBUG
werror("CONFIG: handle_request()\n");
#endif /* REQUEST_DEBUG */
-
- //#if 0
- if(roxen->find_site_for( id ) != this_object()) {
- #ifdef REQUEST_DEBUG
- werror("CONFIG: handle_request(): Redirected (1)\n");
- #endif /* REQUEST_DEBUG */
- return id->conf->handle_request(id);
- }
- //#endif /* 0 */
-
+
foreach(first_modules(id), funp)
{
if(file = funp( id ))
1642:
return id->conf->handle_request(id);
}
}
-
+
if(!mappingp(file) && !mappingp(file = get_file(id)))
{
mixed ret;