SYSLOG("redirecting\n");
SYSLOG("redirecting, rel-path: " + uri->get_relative_path() + ", filename: " + uri->get_filename() + "\n");
int cmd_get(object request, object response){	object	app, uri;	mixed	**list;	string	str;		if(!OWNER()) {		error("illegal call\n");	}		app = get_owner()->get_application();	uri = request->get_uri();	/* if requested file ends with '/', use default page of dir */	str = uri->get_filename();	if(!str || str == "" || str == "/" || str[strlen(str)-1] == '/') {		/* TODO: This is a hack. I guess what we should do is redirect		 * the client		 */		uri->set_filename(					app->default_document(uri->get_absolute_path())				);	}	if(has_access(request, response, READ_ACCESS) == FALSE) {		send(response, TRUE, FALSE);		return FALSE;	}#if 1 /* TODO: This section should probably be reused in [some] other cmds */	list = ::get_dir(uri->get_absolute_filename());	if(sizeof(list[0]) == 0) {		response->set_status(404);		send(response, TRUE, TRUE);		return FALSE;	}	/* redirect user-agent if requested _file_ is a directory */	if(list[1][0] < 0) {		SYSLOG("redirecting\n");		response->set_status(302);		response->set_header("Content-Length", 0);		response->set_header("Location", 				uri->get_relative_path() + uri->get_filename() + "/");		send(response, TRUE, FALSE);		return TRUE;	}	response->set_header("Content-Length", list[1][0]);	response->set_header("Last-Modified", ctime(list[2][0]));#endif#ifdef USE_ETAGS /* TODO: DISABLED ON 04-AUG-2004 DUE TO BUGS, WILL FIX! */	/*	 * Verify set etag and other conditional gets only if plugged in 	 * mediahandlers does not want to deal with this resource.	 */	if(app->get_mediahandler(uri->get_filesuffix()) == nil) {		string etag;		etag = get_etag(uri->get_relative_path() + uri->get_filename(),					"" + list[1][0], ctime(list[2][0]));		response->set_header("Etag", etag);		/* Is their cache up to date? If yes, do not send content. */		if(request->meets_condition(response->get_status(), etag, list[2][0], 					list[1][0]) ) {			response->set_status(304);			response->set_header("Content-Length", 0);			/* TODO: close connection header -- need call_out() in user? */			SYSLOG("Telling client to use its cache...\n");			send(response, TRUE, FALSE);			return TRUE;		}	}#endif /* USE_ETAGS */		/*	 * Check if the mediahandler wants us to read in the content for them	 * before they deal with it; alternatively they read it themselves.	 */	if(app->get_need_content(request, response)) {		int offset, length;		/* read all if mediatype has a mediahandler or it is < CHUNK_SIZE */		if(app->get_mediahandler(uri->get_filesuffix()) != nil ||		  ((int)response->get_header("Content-Length")) <= HTTP_CHUNK_SIZE) {			response->set_read_on_demand(FALSE);			offset = -1;			length = -1;		} else {			response->set_read_on_demand(TRUE);			offset = 0;			length = HTTP_CHUNK_SIZE;		}		if(!(read_resource(request, response, offset, length))) {			LOG("WARNING: could not to read " + uri->get_filename() + "\n");			response->set_status(500);			response->update_content_length();		}		response->set_read_range(offset, length);	}	if(app->handle_mediatype(request, response) == FALSE) {		response->set_status(500);	}	/*	 * If any errors occured in the process of dealing with this mediatype,	 * output them to user's webbrowser.	 */	if(this_user()->has_error()) {		response->add_content( this_user()->get_error() );		response->update_content_length();	}	if(response->get_content_length() == 0) {		response->set_status(204);	}	if(!send(response, TRUE, FALSE)) {		LOG("WARNING: failed to send response\n");	}	return TRUE;}