X-Git-Url: http://git.indexdata.com/?p=yazproxy-moved-to-github.git;a=blobdiff_plain;f=src%2Fyaz-proxy-config.cpp;h=e0dbf5a24ba5e2d01a0432af6321c3baa693fdcd;hp=2bc8cfee52348330ccf22e40e7aacf411a51cc30;hb=d2c4cf45aa3c566c99be2dc305e86371e59b509d;hpb=af0d95244ac549130bd45c54620df98f636984db diff --git a/src/yaz-proxy-config.cpp b/src/yaz-proxy-config.cpp index 2bc8cfe..e0dbf5a 100644 --- a/src/yaz-proxy-config.cpp +++ b/src/yaz-proxy-config.cpp @@ -1,4 +1,4 @@ -/* $Id: yaz-proxy-config.cpp,v 1.11 2004-12-03 14:28:18 adam Exp $ +/* $Id: yaz-proxy-config.cpp,v 1.13 2005-01-18 10:49:22 adam Exp $ Copyright (c) 1998-2004, Index Data. This file is part of the yaz-proxy. @@ -20,7 +20,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA */ #include -#include +#include #include "proxyp.h" class Yaz_ProxyConfigP { @@ -451,6 +451,38 @@ int Yaz_ProxyConfigP::check_schema(xmlNodePtr ptr, Z_RecordComposition *comp, } #endif +const char *Yaz_ProxyConfig::check_mime_type(const char *path) +{ + struct { + const char *mask; + const char *type; + } types[] = { + {".xml", "text/xml"}, + {".xsl", "text/xml"}, + {".tkl", "text/xml"}, + {".xsd", "text/xml"}, + {".html", "text/html"}, + {".jpg", "image/jpeg"}, + {".png", "image/png"}, + {".gif", "image/gif"}, + {0, "text/plain"}, + {0, 0}, + }; + int i; + size_t plen = strlen (path); + for (i = 0; types[i].type; i++) + if (types[i].mask == 0) + return types[i].type; + else + { + size_t mlen = strlen(types[i].mask); + if (plen > mlen && !memcmp(path+plen-mlen, types[i].mask, mlen)) + return types[i].type; + } + return "application/octet-stream"; +} + + int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name, Odr_oid *syntax, Z_RecordComposition *comp, char **addinfo,