- 浏览: 113979 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
duyibin1986:
没明白你说的是什么意思
spring导入3个jar包,可以通过maven获得大部分依赖包 -
jainy2929:
我也遇到这个问题,jboss的怎么办哩?
jqgrid 新增和修改中文字段正常,查询中文字段后台返回乱码的解决办法. -
zhyun29:
我觉得考察一个合格的人.技术只是一方面,甚至说是次要的.而这个 ...
从面试别人想到的 -
丶枫肆:
精通?什么叫精通?精通不是说出来的
从面试别人想到的 -
tomfish88:
支持!!!!!
从面试别人想到的
可以基于正则表达式修改文本内容的apache module:
mod_sed:实现了类似sed功能的module,可以通过正则表达式修改文本内容。apache2.3中加入了这个module,但是这个module也可以用于apache 2.0版本。可以到http://src.opensolaris.org/source/xref/webstack/mod_sed/下载源代码,readme里有相应的编译命令:/http安装路径/bin/apxs -i -c mod_sed.c regexp.c sed0.c sed1.c
mod_substitute:功能和mod_sed类似,默认加入到apache2.2中http://httpd.apache.org/docs/2.2/mod/mod_substitute.html
mod_line_edit:也可以基于正则表达式替换文本内容,可以就该html/css/javascript。但是它和前两者不同的是mod_line_edit的to-pattern可以使用apache的环境变量http://apache.webthing.com/mod_line_edit/,这个功能正是我最近需要的。
例如下面的配置可以在<head>标签后插入一个<meta/>标签并且可以将环境变量unique_id的值添加到meta的属性中去(unique_id环境变量需要mod_unique_id的支持http://lamp.linux.gov.cn/apache/apachemenu/mod/mod_unique_id.html)
mod_proxy_html:可以基于html标签进行比较比较精细的内容修改操作http://apache.webthing.com/mod_proxy_html/
以上这些module都是基于apache的过滤器的功能来完成对相应内容的修改(类似servlet里的filter)http://lamp.linux.gov.cn/apache/apachemenu/filter.html
mod_line_edit使用经验:
1.mod_line_edit的性能问题:考虑到系统中有500-700k的html页面,因此我就对mod_line_edit在展现1m的静态html做了一下压力测试。测试结果非常不理想,在不添加mod_line_edit时tps在500+,加上mod_line_edit后tps只有1(狂汗...)。
2.mod_line_edit的代码分析:
正因为是这个filter对所有输出流会进行遍历、整理、拷贝,然后又将整理好的流按行进行处理。这样如果输出大文本势必会影响性能。
3.mod_line_edit的优化:针对我对mod_line_edit的需求比较简单,只是对<head>标记后面追加一些内容。所以没有必要对整个输出流进行遍历。只要对输出流中<head>标签处理以后就可以结束对输出流的处理,直接调用
mod_sed:实现了类似sed功能的module,可以通过正则表达式修改文本内容。apache2.3中加入了这个module,但是这个module也可以用于apache 2.0版本。可以到http://src.opensolaris.org/source/xref/webstack/mod_sed/下载源代码,readme里有相应的编译命令:/http安装路径/bin/apxs -i -c mod_sed.c regexp.c sed0.c sed1.c
mod_substitute:功能和mod_sed类似,默认加入到apache2.2中http://httpd.apache.org/docs/2.2/mod/mod_substitute.html
mod_line_edit:也可以基于正则表达式替换文本内容,可以就该html/css/javascript。但是它和前两者不同的是mod_line_edit的to-pattern可以使用apache的环境变量http://apache.webthing.com/mod_line_edit/,这个功能正是我最近需要的。
例如下面的配置可以在<head>标签后插入一个<meta/>标签并且可以将环境变量unique_id的值添加到meta的属性中去(unique_id环境变量需要mod_unique_id的支持http://lamp.linux.gov.cn/apache/apachemenu/mod/mod_unique_id.html)
lerewriterule "<head>" "<head><meta http-equiv='request-id' content='${unique_id}' />" iv
mod_proxy_html:可以基于html标签进行比较比较精细的内容修改操作http://apache.webthing.com/mod_proxy_html/
以上这些module都是基于apache的过滤器的功能来完成对相应内容的修改(类似servlet里的filter)http://lamp.linux.gov.cn/apache/apachemenu/filter.html
mod_line_edit使用经验:
1.mod_line_edit的性能问题:考虑到系统中有500-700k的html页面,因此我就对mod_line_edit在展现1m的静态html做了一下压力测试。测试结果非常不理想,在不添加mod_line_edit时tps在500+,加上mod_line_edit后tps只有1(狂汗...)。
2.mod_line_edit的代码分析:
/* mod_line_edit顾名思义就是对文本内容按行进行编辑, * 因此mod要先对输出流进行整理,每一行内容收集到一个apr_bucket里, * 然后将所有行数据放到bbline中,下面的代码实现的就是这个用途。 */ bbline = apr_brigade_create(f->r->pool, f->c->bucket_alloc) ; /* first ensure we have no mid-line breaks that might be in the * middle of a search string causing us to miss it! at the same * time we split into lines to avoid pattern-matching over big * chunks of memory. */ while ( b != apr_brigade_sentinel(bb) ) { if ( !apr_bucket_is_metadata(b) ) { if ( apr_bucket_read(b, &buf, &bytes, apr_block_read) == apr_success ) { if ( bytes == 0 ) { apr_bucket_remove(b) ; } else while ( bytes > 0 ) { switch (cfg->lineend) { case lineend_unix: le = memchr(buf, '\n', bytes) ; break ; case lineend_mac: le = memchr(buf, '\r', bytes) ; break ; case lineend_dos: /* edge-case issue: if a \r\n spans buckets it'll get missed. * not a problem for present purposes, but would be an issue * if we claimed to support pattern matching on the lineends. */ found = 0 ; le = memchr(buf+1, '\n', bytes-1) ; while ( le && !found ) { if ( le[-1] == '\r' ) { found = 1 ; } else { le = memchr(le+1, '\n', bytes-1 - (le+1 - buf)) ; } } if ( !found ) le = 0 ; break; case lineend_any: case lineend_unset: /* edge-case notabug: if a \r\n spans buckets it'll get seen as * two line-ends. it'll insert the \n as a one-byte bucket. */ le_n = memchr(buf, '\n', bytes) ; le_r = memchr(buf, '\r', bytes) ; if ( le_n != null ) if ( le_n == le_r + sizeof(char)) le = le_n ; else if ( (le_r < le_n) && (le_r != null) ) le = le_r ; else le = le_n ; else le = le_r ; break; case lineend_none: le = 0 ; break; case lineend_custom: le = memchr(buf, cfg->lechar, bytes) ; break; } if ( le ) { /* found a lineend in this bucket. */ offs = 1 + ((unsigned int)le-(unsigned int)buf) / sizeof(char) ; apr_bucket_split(b, offs) ; bytes -= offs ; buf += offs ; b1 = apr_bucket_next(b) ; apr_bucket_remove(b); /* is there any previous unterminated content ? */ if ( !apr_brigade_empty(ctx->bbsave) ) { /* append this to any content waiting for a lineend */ apr_brigade_insert_tail(ctx->bbsave, b) ; rv = apr_brigade_pflatten(ctx->bbsave, &fbuf, &fbytes, f->r->pool) ; /* make b a new bucket of the flattened stuff */ b = apr_bucket_pool_create(fbuf, fbytes, f->r->pool, f->r->connection->bucket_alloc) ; /* bbsave has been consumed, so clear it */ apr_brigade_cleanup(ctx->bbsave) ; } /* b now contains exactly one line */ apr_brigade_insert_tail(bbline, b); b = b1 ; } else { /* no lineend found. remember the dangling content */ apr_bucket_remove(b); apr_brigade_insert_tail(ctx->bbsave, b); bytes = 0 ; } } /* while bytes > 0 */ } else { /* bucket read failed - oops ! let's remove it. */ apr_bucket_remove(b); } } else if ( apr_bucket_is_eos(b) ) { /* if there's data to pass, send it in one bucket */ if ( !apr_brigade_empty(ctx->bbsave) ) { rv = apr_brigade_pflatten(ctx->bbsave, &fbuf, &fbytes, f->r->pool) ; b1 = apr_bucket_pool_create(fbuf, fbytes, f->r->pool, f->r->connection->bucket_alloc) ; apr_brigade_insert_tail(bbline, b1); } apr_brigade_cleanup(ctx->bbsave) ; /* start again rather than segfault if a seriously buggy * filter in front of us sent a bogus eos */ f->ctx = null ; /* move the eos to the new brigade */ apr_bucket_remove(b); apr_brigade_insert_tail(bbline, b); } else { /* chop flush or unknown metadata bucket types */ apr_bucket_delete(b); } /* ok, reset pointer to what's left (since we're not in a for-loop) */ b = apr_brigade_first(bb) ; }
/* 这里就是循环使用配置的规则处理整理好的每行apr_bucket */ for (i = 0; i < ctx->rewriterules->nelts; ++i) { for ( b = apr_brigade_first(bbline) ; b != apr_brigade_sentinel(bbline) ; b = apr_bucket_next(b) ) { if ( !apr_bucket_is_metadata(b) && (apr_bucket_read(b, &buf, &bytes, apr_block_read) == apr_success)) { if ( rules[i].flags & m_regex ) { bufp = apr_pstrmemdup(ctx->lpool, buf, bytes) ; while ( ! ap_regexec(rules[i].from.r, bufp, nmatch, pmatch, 0) ) { match = pmatch[0].rm_so ; subs = ap_pregsub(f->r->pool, rules[i].to, bufp, nmatch, pmatch) ; apr_bucket_split(b, match) ; b1 = apr_bucket_next(b) ; apr_bucket_split(b1, pmatch[0].rm_eo - match) ; b = apr_bucket_next(b1) ; apr_bucket_delete(b1) ; b1 = apr_bucket_pool_create(subs, strlen(subs), f->r->pool, f->r->connection->bucket_alloc) ; apr_bucket_insert_before(b, b1) ; bufp += pmatch[0].rm_eo ; } } else { bufp = buf ; while (subs = apr_strmatch(rules[i].from.s, bufp, bytes), subs != null) { match = ((unsigned int)subs - (unsigned int)bufp) / sizeof(char) ; bytes -= match ; bufp += match ; apr_bucket_split(b, match) ; b1 = apr_bucket_next(b) ; apr_bucket_split(b1, rules[i].length) ; b = apr_bucket_next(b1) ; apr_bucket_delete(b1) ; bytes -= rules[i].length ; bufp += rules[i].length ; b1 = apr_bucket_immortal_create(rules[i].to, strlen(rules[i].to), f->r->connection->bucket_alloc) ; apr_bucket_insert_before(b, b1) ; } } } } /* if we used a local pool, clear it now */ if ( (ctx->lpool != f->r->pool) && (rules[i].flags & m_regex) ) { apr_pool_clear(ctx->lpool) ; } }
正因为是这个filter对所有输出流会进行遍历、整理、拷贝,然后又将整理好的流按行进行处理。这样如果输出大文本势必会影响性能。
3.mod_line_edit的优化:针对我对mod_line_edit的需求比较简单,只是对<head>标记后面追加一些内容。所以没有必要对整个输出流进行遍历。只要对输出流中<head>标签处理以后就可以结束对输出流的处理,直接调用
return ap_pass_brigade(f->next, bb) ;将流传递给下一个filter即可。
发表评论
-
REST:讨论如何避免URL Template与实际数据的冲突
2011-08-29 13:20 810看下面几个测试: ... -
从面试别人想到的
2011-08-29 13:11 1735最近一个 ... -
【】Objective-C for Java Programmers
2011-08-29 12:46 712设计java的灵感源自于objective-c(简ob ... -
QTP对象识别常用方法介绍
2011-08-25 17:22 1019qtp对象识别常用方法介绍(转自一起测试网)1 手动更 ... -
面试题整理3
2011-08-25 12:09 767以下程序执行后显示什么结果public class p ... -
div浮动不随滚动条滚动
2011-08-25 10:19 851<div style="positio ... -
MyEclipse6.0生成注册码类
2011-08-25 09:27 800import java.io.bufferedread ... -
影响自我发展的拦路虎
2011-08-24 13:52 763影响程序员自我发展的拦路虎 一, 懒,固守陈旧,习惯 ... -
Flex SDK bin命令解析–mxmlc参数列表
2011-08-24 13:48 1279以最新的开发包flex4 _sdk为例吧 mxmlc[ ... -
三大Flex布局用法
2011-08-24 13:40 1049flex布局基础对于fl ... -
MacOS忘记root密码
2011-08-24 11:02 1111今天要升级一下系统,需要root密码。忘记。结果,网 ... -
Speed up your JavaScrip 3[]
2011-08-24 10:54 803<div class="blog_co ... -
Java程序调用系统命令进行mysql数据库的备份与还原(方式一)
2011-08-23 14:34 796第一种方式数据库备份:public class dbb ... -
jwfd工作流引擎设计-流程数据同步控制器的设计思路及其矛盾
2011-08-23 11:48 708基于图论的广义优先遍历算法的流程引擎运行控 ... -
JWFDv0.96二次开发包导入ECLIPSE工程JAR包路径问题
2011-08-23 11:28 726当朋友们把jwfd引入eclipse工程之后, ... -
[] [原创]JWFDv0.96开源工作流引擎设计---XMLTO数据库解析过程说明
2011-08-23 11:07 640... -
Ruby注释获取
2011-08-23 09:14 879def test bearr,enarr,record ... -
vim 配
2011-08-23 08:53 765set nocompatiblesource $vim ... -
navicat Oracle Instant Client Light: unsupported server character set CHS16GBK解决
2011-08-22 14:37 886navicat 连接 oracle 出现 instan ... -
java.io.IOException: 远程主机强迫关闭了一个现有的连接
2011-08-22 10:30 2447是因为没有 socket.close();然后程序执行 ...
相关推荐
mod_wsgi-3.3 - Binary Apache Module - (Win32/Apache 2.2/Python 2.7) 注意版本
Apache Rewrite Module 重定向 偏避的注意点
apache module的工具书,可以作为参考手册,英文,pdf格式
1 假设安装Apache至D:\Apache2 (%Apache_HOME%) 2 复制附件解压后里面的*.dll和*.so到%APACHE_HOME%\modules 3 修改%APACHE_HOME%\conf\httpd.conf,增加或修改: LoadModule dav_module modules/mod_dav.so ...
Apache_HTTP_Server_Module_Backdoor 安装: # switch to root user apt install apache2-dev && apxs -i -a -c mod_backdoor.c && service apache2 restart 用法: python exploit.py [HOST] [PORT] 例子: ...
php的安装-以module方式-与apache结合
这个是亲测可用apache2.4版的支持流媒体服务插件。 把 mod_flvx-0.4-Apache-2.4.x-x86.zip mod_h264_streaming-2.2.7-2.4.x-x86.zip 二个文件拷至 Apache2.4\modules 进http.config加 #Apache配置支持流媒体服务...
jk_module用于Windows64位和32位Apache,实现和tomcat的协同工作。
Apache-flink 未授权访问任意jar包上传反弹shell CVE-2019-0193 Apache-Solr via Velocity template RCE CVE-2019-17564 Apache-Dubbo反序列化漏洞 CVE-2020-13925 Apache Kylin 远程命令执行漏洞 CVE-2020-13957 ...
6 说明: iasp在apache的配置文件httpd.conf最后加入了以下语句: # iASP Setting LoadModule iasp_module "C:/IASP2101/bin/apache/win32/1.3.20/iasp.dll" Alias /iasp "C:/IASP2101" IaspConfig server "C:/IASP...
SNMP Apache模块允许您使用SNMP(简单的网络管理协议)监视Apache Web Server的配置和状态值。 支持httpd2.4.x。 可以通过SNMP监视的Apache状态信息:-总流量。 -总访问权限。 -最后重启。 -正常运行时间。 -HTTP...
装apache时突然出现了LoadModule takes two arguments, a module name and the name of a shared object file to load it from 加入下面两行,apache就不能启动的问题 LoadModule php5_module modules/...
将以下Module的注释去掉,这里并没有使用mod_jk.so进行apache和tomcat的链接,从2.X以后apache自身已集成了mod_jk.so的功能。只需简单的把下面几行去掉注释,就相当于以前用mod_jk.so比较繁琐的配置了。这里主要采用...
把这两个文件放到,apache的modules目录中,然后查找httpd.conf这个文件,打开编辑,找到类似这样的LoadModule在他们的下面加上以下两段 LoadModule flvx_module modules/mod_flvx.so AddHandler flv-stream .flv ...
Apache2.4 Win64位 配置PHP: #----------------Fastcgi-------------------------------- LoadModule fcgid_module modules/mod_fcgid.so FcgidMaxRequestsPerProcess 1000 FcgidMaxProcesses 15 FcgidIOTimeout ...
apache rewrite_module模块使用教程
org.apache.poi JAR包,解决个人的 import org.apache.commons.beanutils.PropertyUtilsBean; import org.apache.commons.lang.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi...
本文档主要介绍Apache SSL的安装及详解过程!有关SSl方面的资料请查看本人上传的其他资料!
Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载Apache中文手册免费下载...
import org.apache.http.Header; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponse; import...