[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[myserver-commit] [2991] Allow possibiity to define values on a MIME typ
From: |
Giuseppe Scrivano |
Subject: |
[myserver-commit] [2991] Allow possibiity to define values on a MIME type. |
Date: |
Sun, 01 Feb 2009 14:59:19 +0000 |
Revision: 2991
http://svn.sv.gnu.org/viewvc/?view=rev&root=myserver&revision=2991
Author: gscrivano
Date: 2009-02-01 14:59:19 +0000 (Sun, 01 Feb 2009)
Log Message:
-----------
Allow possibiity to define values on a MIME type.
Modified Paths:
--------------
trunk/myserver/documentation/mime_types.texi
trunk/myserver/include/conf/mime/mime_manager.h
trunk/myserver/include/conf/security/security_token.h
trunk/myserver/src/conf/mime/mime_manager.cpp
trunk/myserver/src/conf/security/security_token.cpp
Modified: trunk/myserver/documentation/mime_types.texi
===================================================================
--- trunk/myserver/documentation/mime_types.texi 2009-02-01 14:58:30 UTC
(rev 2990)
+++ trunk/myserver/documentation/mime_types.texi 2009-02-01 14:59:19 UTC
(rev 2991)
@@ -11,6 +11,7 @@
<MIME mime="text/html" handler="RUNCGI" param="/usr/bin/perl"
selfExecuted="NO">
<FILTER value="gzip"/>
<EXTENSION value="pl"/>
+<DEFINE name="http.error.file.404" value="404.html"/>
</MIME>
@end example
@@ -47,6 +48,10 @@
It is possible to specify multiple filters for the same MIME type,
they will be applied in the specified order.
address@hidden<DEFINE>} It defines a new value for a variable, take a look
+here @xref{Security files} for more details on the @code{<DEFINE>}
+element.
+
The same MIME type can have several extensions, you will need to
specify a different @code{<EXTENSION>} element for each extension.
Modified: trunk/myserver/include/conf/mime/mime_manager.h
===================================================================
--- trunk/myserver/include/conf/mime/mime_manager.h 2009-02-01 14:58:30 UTC
(rev 2990)
+++ trunk/myserver/include/conf/mime/mime_manager.h 2009-02-01 14:59:19 UTC
(rev 2991)
@@ -1,7 +1,7 @@
/* -*- mode: c++ -*- */
/*
MyServer
-Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -62,12 +62,14 @@
string cgiManager;
bool selfExecuted;
list<Regex*> pathRegex;
+ HashMap<string, string*> hashedData;
MimeRecord ();
MimeRecord (MimeRecord&);
int addFilter (const char*, bool acceptDuplicate = true);
~MimeRecord ();
void clear ();
+ const char* getHashedData(string &name);
};
class MimeManager
Modified: trunk/myserver/include/conf/security/security_token.h
===================================================================
--- trunk/myserver/include/conf/security/security_token.h 2009-02-01
14:58:30 UTC (rev 2990)
+++ trunk/myserver/include/conf/security/security_token.h 2009-02-01
14:59:19 UTC (rev 2991)
@@ -1,7 +1,7 @@
/* -*- mode: c++ -*- */
/*
MyServer
-Copyright (C) 2002, 2003, 2004, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2008, 2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -28,17 +28,21 @@
class Server;
class Vhost;
+struct MimeRecord;
enum SECURITY_RING
{
/*! Security file configuration. */
- MYSERVER_SECURITY_CONF = (1<<0),
+ MYSERVER_SECURITY_CONF = (1 << 0),
/*! Virtual host configuration. */
- MYSERVER_VHOST_CONF = (1<<1),
+ MYSERVER_VHOST_CONF = (1 << 1),
+ /*! Mime type. */
+ MYSERVER_MIME_CONF = (1 << 2),
+
/*! Global server configuration. */
- MYSERVER_SERVER_CONF = (1<<2),
+ MYSERVER_SERVER_CONF = (1 << 3),
};
class SecurityToken
@@ -175,6 +179,16 @@
vhost = v;
}
+ MimeRecord *getMime ()
+ {
+ return mimeRecord;
+ }
+
+ void setMime (MimeRecord *mr)
+ {
+ mimeRecord = mr;
+ }
+
private:
/*! User to check for. */
string user;
@@ -214,10 +228,13 @@
bool done;
/*! Server instance. */
- Server* server;
+ Server *server;
/*! VHost. */
- Vhost* vhost;
+ Vhost *vhost;
+
+ MimeRecord *mimeRecord;
+
};
#endif
Modified: trunk/myserver/src/conf/mime/mime_manager.cpp
===================================================================
--- trunk/myserver/src/conf/mime/mime_manager.cpp 2009-02-01 14:58:30 UTC
(rev 2990)
+++ trunk/myserver/src/conf/mime/mime_manager.cpp 2009-02-01 14:59:19 UTC
(rev 2991)
@@ -1,6 +1,6 @@
/*
MyServer
-Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2002, 2003, 2004, 2006, 2007, 2008, 2009 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -115,10 +115,30 @@
delete *it;
}
+ HashMap<string, string*>::Iterator it = hashedData.begin();
+ for (;it != hashedData.end(); it++)
+ {
+ delete (*it);
+ }
+ hashedData.clear();
+
+
pathRegex.clear ();
}
/*!
+ *Get the value stored in the hash dictionary for the `name' key.
+ */
+const char* MimeRecord::getHashedData(string &name)
+{
+ string *str = hashedData.get (name);
+ if (str)
+ return str->c_str ();
+
+ return NULL;
+}
+
+/*!
*Get the name of the file opened by the class.
*/
const char *MimeManager::getFilename ()
@@ -153,6 +173,8 @@
}
+
+
for ( ;lcur; lcur = lcur->next)
{
if (lcur->name && !xmlStrcmp(lcur->name, (const xmlChar *)"EXTENSION"))
@@ -168,6 +190,31 @@
}
}
+ if (lcur->name && !xmlStrcmp(lcur->name, (const xmlChar *)"DEFINE"))
+ {
+ const char *name = NULL;
+ const char *value = NULL;
+
+ for (attrs = lcur->properties; attrs; attrs = attrs->next)
+ {
+ if (!xmlStrcmp (attrs->name, (const xmlChar *)"name") &&
+ attrs->children && attrs->children->content)
+ name = (const char*)attrs->children->content;
+
+ if (!xmlStrcmp (attrs->name, (const xmlChar *)"value") &&
+ attrs->children && attrs->children->content)
+ value = (const char*)attrs->children->content;
+ }
+
+ if (name && value)
+ {
+ string key (name);
+ string *v = new string (value);
+ rc->hashedData.put(key, v);
+ }
+
+ }
+
if (lcur->name && !xmlStrcmp(lcur->name, (const xmlChar *)"PATH"))
{
for (attrs = lcur->properties; attrs; attrs = attrs->next)
Modified: trunk/myserver/src/conf/security/security_token.cpp
===================================================================
--- trunk/myserver/src/conf/security/security_token.cpp 2009-02-01 14:58:30 UTC
(rev 2990)
+++ trunk/myserver/src/conf/security/security_token.cpp 2009-02-01 14:59:19 UTC
(rev 2991)
@@ -1,6 +1,6 @@
/*
MyServer
-Copyright (C) 2002-2008 Free Software Foundation, Inc.
+Copyright (C) 2002-2009 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
@@ -43,7 +43,7 @@
done = false;
server = NULL;
vhost = NULL;
-
+ mimeRecord = NULL;
directory = NULL;
sysdirectory = NULL;
resource = NULL;
@@ -69,7 +69,15 @@
if (ret)
return ret->c_str ();
+ }
+ if (mimeRecord && (domains & MYSERVER_MIME_CONF))
+ {
+ string strName (name);
+ const char *ret = mimeRecord->getHashedData (strName);
+
+ if (ret)
+ return ret;
}
if (vhost && (domains & MYSERVER_VHOST_CONF))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [myserver-commit] [2991] Allow possibiity to define values on a MIME type.,
Giuseppe Scrivano <=