metaproxy  1.21.0
Classes | Public Member Functions | Private Attributes | List of all members
metaproxy_1::filter::HttpFile Class Reference

#include <filter_http_file.hpp>

Inheritance diagram for metaproxy_1::filter::HttpFile:
Inheritance graph
Collaboration diagram for metaproxy_1::filter::HttpFile:
Collaboration graph

Classes

struct  Area
 
class  Mime
 
class  Rep
 

Public Member Functions

 HttpFile ()
 
 ~HttpFile ()
 
void process (metaproxy_1::Package &package) const
 
void configure (const xmlNode *ptr, bool test_only, const char *path)
 

Private Attributes

boost::scoped_ptr< Repm_p
 

Detailed Description

Definition at line 28 of file filter_http_file.hpp.

Constructor & Destructor Documentation

◆ HttpFile()

mp::filter::HttpFile::HttpFile ( )

Definition at line 89 of file filter_http_file.cpp.

89  : m_p(new Rep)
90 {
91 #if 0
92  m_p->m_ext_to_map["html"] = Mime("text/html");
93  m_p->m_ext_to_map["htm"] = Mime("text/html");
94  m_p->m_ext_to_map["png"] = Mime("image/png");
95  m_p->m_ext_to_map["txt"] = Mime("text/plain");
96  m_p->m_ext_to_map["text"] = Mime("text/plain");
97  m_p->m_ext_to_map["asc"] = Mime("text/plain");
98  m_p->m_ext_to_map["xml"] = Mime("application/xml");
99  m_p->m_ext_to_map["xsl"] = Mime("application/xml");
100 #endif
101 #if 0
102  Area a;
103  a.m_url_path_prefix = "/etc";
104  a.m_file_root = ".";
105  m_p->m_area_list.push_back(a);
106 #endif
107 }
boost::scoped_ptr< Rep > m_p

References metaproxy_1::filter::HttpFile::Area::m_file_root, m_p, and metaproxy_1::filter::HttpFile::Area::m_url_path_prefix.

◆ ~HttpFile()

mp::filter::HttpFile::~HttpFile ( )

Definition at line 109 of file filter_http_file.cpp.

110 {
111 }

Member Function Documentation

◆ configure()

void mp::filter::HttpFile::configure ( const xmlNode *  ptr,
bool  test_only,
const char *  path 
)

Definition at line 283 of file filter_http_file.cpp.

285 {
286  for (ptr = ptr->children; ptr; ptr = ptr->next)
287  {
288  if (ptr->type != XML_ELEMENT_NODE)
289  continue;
290  if (!strcmp((const char *) ptr->name, "mimetypes"))
291  {
292  std::string fname = mp::xml::get_text(ptr);
293 
294  mp::PlainFile f;
295 
296  if (!f.open(fname))
297  {
298  throw mp::filter::FilterException
299  ("Can not open mime types file " + fname);
300  }
301 
302  std::vector<std::string> args;
303  while (f.getline(args))
304  {
305  size_t i;
306  for (i = 1; i<args.size(); i++)
307  m_p->m_ext_to_map[args[i]] = args[0];
308  }
309  }
310  else if (!strcmp((const char *) ptr->name, "area"))
311  {
312  xmlNode *a_node = ptr->children;
313  Area a;
314 
315  for (; a_node; a_node = a_node->next)
316  {
317  if (a_node->type != XML_ELEMENT_NODE)
318  continue;
319 
320  if (mp::xml::is_element_mp(a_node, "documentroot"))
321  a.m_file_root = mp::xml::get_text(a_node);
322  else if (mp::xml::is_element_mp(a_node, "prefix"))
323  a.m_url_path_prefix = mp::xml::get_text(a_node);
324  else if (mp::xml::is_element_mp(a_node, "raw"))
325  a.m_raw = mp::xml::get_bool(a_node, false);
326  else if (mp::xml::is_element_mp(a_node, "passthru"))
327  a.m_passthru = mp::xml::get_bool(a_node, false);
328  else
329  throw mp::filter::FilterException
330  ("Bad element "
331  + std::string((const char *) a_node->name)
332  + " in area section"
333  );
334  }
335  if (a.m_file_root.length())
336  {
337  m_p->m_area_list.push_back(a);
338  }
339  }
340  else
341  {
342  throw mp::filter::FilterException
343  ("Bad element "
344  + std::string((const char *) ptr->name)
345  + " in virt_db filter");
346  }
347  }
348 }

References metaproxy_1::filter::HttpFile::Area::m_file_root, metaproxy_1::filter::HttpFile::Area::m_passthru, metaproxy_1::filter::HttpFile::Area::m_raw, and metaproxy_1::filter::HttpFile::Area::m_url_path_prefix.

◆ process()

void mp::filter::HttpFile::process ( metaproxy_1::Package &  package) const

Definition at line 274 of file filter_http_file.cpp.

275 {
276  Z_GDU *gdu = package.request().get();
277  if (gdu && gdu->which == Z_GDU_HTTP_Request)
278  m_p->fetch_uri(package.session(), gdu->u.HTTP_Request, package);
279  else
280  package.move();
281 }

Member Data Documentation

◆ m_p

boost::scoped_ptr<Rep> metaproxy_1::filter::HttpFile::m_p
private

Definition at line 32 of file filter_http_file.hpp.

Referenced by HttpFile().


The documentation for this class was generated from the following files: