|
| Phase () |
|
void | read_skip_headers (Z_HTTP_Request *hreq, std::list< boost::regex > &skip_list, std::string bind_addr) |
|
void | rewrite_reqline (mp::odr &o, Z_HTTP_Request *hreq, std::map< std::string, std::string > &vars, std::string bind_addr) const |
|
void | rewrite_headers (mp::odr &o, Z_HTTP_Header *headers, std::map< std::string, std::string > &vars) const |
|
void | rewrite_body (mp::odr &o, const char *content_type, char **content_buf, int *content_len, std::map< std::string, std::string > &vars, std::list< boost::regex > &skip_list) const |
|
Definition at line 87 of file filter_http_rewrite.cpp.
◆ Phase()
mp::filter::HttpRewrite::Phase::Phase |
( |
| ) |
|
◆ read_skip_headers()
void mp::filter::HttpRewrite::Phase::read_skip_headers |
( |
Z_HTTP_Request * |
hreq, |
|
|
std::list< boost::regex > & |
skip_list, |
|
|
std::string |
bind_addr |
|
) |
| |
Definition at line 182 of file filter_http_rewrite.cpp.
186 std::string url(hreq->path);
187 if ( url.substr(0,7) !=
"http://" && url.substr(0,8) !=
"https://")
190 const char *host = z_HTTP_header_lookup(hreq->headers,
"Host");
192 if (bind_addr.find(
"ssl:") == 0) {
198 url = proto +
"://" + std::string(host) + hreq->path ;
201 while (
const char *hv = z_HTTP_header_remove( &(hreq->headers),
202 "X-Metaproxy-SkipLink") )
204 yaz_log(YLOG_LOG,
"Found SkipLink '%s'", hv );
205 const char *p = strchr(hv,
' ');
208 std::string page(hv,p);
209 std::string link(p+1);
210 boost::regex pagere(page);
211 if ( boost::regex_search(url, pagere) )
213 yaz_log(YLOG_LOG,
"SkipLink '%s' matches URL %s",
214 page.c_str(), url.c_str() );
215 boost::regex linkre(link);
216 skip_list.push_back(linkre);
220 yaz_log(YLOG_LOG,
"SkipLink ignored, '%s' does not match '%s'",
221 url.c_str(), page.c_str() );
◆ rewrite_body()
void mp::filter::HttpRewrite::Phase::rewrite_body |
( |
mp::odr & |
o, |
|
|
const char * |
content_type, |
|
|
char ** |
content_buf, |
|
|
int * |
content_len, |
|
|
std::map< std::string, std::string > & |
vars, |
|
|
std::list< boost::regex > & |
skip_list |
|
) |
| const |
Definition at line 313 of file filter_http_rewrite.cpp.
321 if (*content_len == 0)
324 yaz_log(YLOG_LOG,
"rewrite_body: null content_type, can not rewrite");
327 std::list<Content>::const_iterator cit =
content_list.begin();
330 yaz_log(YLOG_LOG,
"rewrite_body: content_type=%s type=%s",
331 content_type, cit->type.c_str());
332 if (cit->type !=
"headers"
333 && regex_match(content_type, cit->content_re))
337 yaz_log(YLOG_LOG,
"rewrite_body: No content rule matched %s, not rewriting",
343 for (i = 0; i < *content_len; i++)
344 if ((*content_buf)[i] == 0) {
345 yaz_log(YLOG_LOG,
"rewrite_body: Looks like binary stuff, not rewriting");
349 std::string content(*content_buf, *content_len);
350 cit->parse(
m_verbose, content, vars, skip_list);
351 *content_buf = odr_strdup(o, content.c_str());
352 *content_len = strlen(*content_buf);
◆ rewrite_headers()
void mp::filter::HttpRewrite::Phase::rewrite_headers |
( |
mp::odr & |
o, |
|
|
Z_HTTP_Header * |
headers, |
|
|
std::map< std::string, std::string > & |
vars |
|
) |
| const |
Definition at line 281 of file filter_http_rewrite.cpp.
285 std::list<Content>::const_iterator cit =
content_list.begin();
287 if (cit->type ==
"headers")
293 for (Z_HTTP_Header *header = headers; header; header = header->next)
295 std::list<Within>::const_iterator it = cit->within_list.begin();
296 for (; it != cit->within_list.end(); it++)
298 if (!it->header.empty() &&
299 regex_match(header->name, it->header))
302 std::string hval(header->value);
303 std::list<boost::regex> dummy_skip_list;
304 if (it->exec(vars, hval,
true, dummy_skip_list))
306 header->value = odr_strdup(o, hval.c_str());
◆ rewrite_reqline()
void mp::filter::HttpRewrite::Phase::rewrite_reqline |
( |
mp::odr & |
o, |
|
|
Z_HTTP_Request * |
hreq, |
|
|
std::map< std::string, std::string > & |
vars, |
|
|
std::string |
bind_addr |
|
) |
| const |
Definition at line 227 of file filter_http_rewrite.cpp.
233 if (bind_addr.find(
"ssl:") == 0) {
238 yaz_log(YLOG_LOG,
"rewrite_reqline: p='%s' ba='%s'",
239 hreq->path, proto.c_str() );
241 if ((strstr(hreq->path,
"http://") == hreq->path) ||
242 (strstr(hreq->path,
"https://") == hreq->path) )
244 yaz_log(YLOG_LOG,
"Path in the method line is absolute, "
245 "possibly a proxy request");
250 const char *host = z_HTTP_header_lookup(hreq->headers,
"Host");
254 path = proto +
"://";
259 std::list<Content>::const_iterator cit =
content_list.begin();
261 if (cit->type ==
"headers")
267 std::list<Within>::const_iterator it = cit->within_list.begin();
268 for (; it != cit->within_list.end(); it++)
271 yaz_log(YLOG_LOG,
"Proxy request URL is %s", path.c_str());
272 std::list<boost::regex> dummy_skip_list;
273 if (it->exec(vars, path,
true, dummy_skip_list))
275 yaz_log(YLOG_LOG,
"Rewritten request URL is %s", path.c_str());
276 hreq->path = odr_strdup(o, path.c_str());
◆ content_list
std::list<Content> metaproxy_1::filter::HttpRewrite::Phase::content_list |
◆ m_verbose
int metaproxy_1::filter::HttpRewrite::Phase::m_verbose |
The documentation for this class was generated from the following file: