metaproxy  1.21.0
Private Member Functions | Private Attributes | Friends | List of all members
metaproxy_1::filter::HttpRewrite1::Rep Class Reference
Collaboration diagram for metaproxy_1::filter::HttpRewrite1::Rep:
Collaboration graph

Private Member Functions

void rewrite_response (mp::odr &o, Z_HTTP_Response *hres)
 

Private Attributes

std::list< Rulerules
 

Friends

class HttpRewrite1
 

Detailed Description

Definition at line 50 of file filter_http_rewrite1.cpp.

Member Function Documentation

◆ rewrite_response()

void mp::filter::HttpRewrite1::Rep::rewrite_response ( mp::odr &  o,
Z_HTTP_Response *  hres 
)
private

Definition at line 66 of file filter_http_rewrite1.cpp.

67 {
68  const char *ctype = z_HTTP_header_lookup(hres->headers, "Content-Type");
69  if (ctype && hres->content_buf)
70  {
71  std::string text(hres->content_buf, hres->content_len);
72  std::list<Rule>::const_iterator it;
73  int number_of_replaces = 0;
74  for (it = rules.begin(); it != rules.end(); it++)
75  {
76  if (strcmp(ctype, it->content_type.c_str()) == 0)
77  {
78  boost::regex::flag_type b_mode = boost::regex::perl;
79  if (it->mode.find_first_of('i') != std::string::npos)
80  b_mode |= boost::regex::icase;
81  boost::regex e(it->pattern, b_mode);
82  boost::match_flag_type match_mode = boost::format_first_only;
83  if (it->mode.find_first_of('g') != std::string::npos)
84  match_mode = boost::format_all;
85  text = regex_replace(text, e, it->replacement, match_mode);
86  number_of_replaces++;
87  }
88  }
89  if (number_of_replaces > 0)
90  {
91  hres->content_buf = odr_strdup(o, text.c_str());
92  hres->content_len = strlen(hres->content_buf);
93  }
94  }
95 }

Friends And Related Function Documentation

◆ HttpRewrite1

friend class HttpRewrite1
friend

Definition at line 51 of file filter_http_rewrite1.cpp.

Member Data Documentation

◆ rules

std::list<Rule> metaproxy_1::filter::HttpRewrite1::Rep::rules
private

Definition at line 53 of file filter_http_rewrite1.cpp.


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