<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link href="http://feed.feedsky.com/whoisme" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/whoisme" type="application/rss+xml"></fs:self_link><lastBuildDate>Tue, 18 May 2010 06:48:18 GMT</lastBuildDate><title>who is me</title><description>yet another blog of georgexsh</description><link>http://xerr.net</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Tue, 29 Jun 2010 09:37:52 GMT</pubDate><item><title>grep匹配tab</title><link>http://xerr.net/2010/05/grep-tab.html</link><content:encoded>&lt;p&gt;今天有同学问如何用 grep 匹配 tab，想到这么几个方法：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;在匹配模式里写上一个&lt;strong&gt;真正&lt;/strong&gt;的 tab (bash下)：&lt;code&gt;&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;grep foo$'\t'bar …&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;[ESC] tab&lt;/code&gt; OR &lt;code&gt;C-v tab&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;用 awk：&lt;code&gt;awk '/\t/' …&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;有支持 PCRE 的 grep (编译时没有打开 &lt;code&gt;--disable-perl-regexp&lt;/code&gt;)，加上开关 &lt;code&gt;-P&lt;/code&gt; : &lt;code&gt;grep –P '\t' …&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;换个&lt;strong&gt;真正&lt;/strong&gt;的工具：&lt;code&gt;perl&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641526/whoisme/feedsky/s.gif?r=http://xerr.net/2010/05/grep-tab.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641526/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641526/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641526/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641526/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2010/05/grep-tab.html/feed</wfw:commentRss><slash:comments>1</slash:comments><fs:srclink>http://xerr.net/2010/05/grep-tab.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641526/5453343</fs:itemid><description>今天有同学问如何用 grep 匹配 tab，想到这么几个方法： 在匹配模式里写上一个真正的 tab (bash下)： grep foo$'\t'bar … [ESC] tab OR C-v tab 用 awk：awk '/\t/' … 有支持 PCRE 的 grep (编译时没有打开 --disable-perl-regexp)，加上开关 -P : grep –P '\t' … 换个真正的工具：perl&lt;img src=&quot;http://www1.feedsky.com/t1/407641526/whoisme/feedsky/s.gif?r=http://xerr.net/2010/05/grep-tab.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641526/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641526/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641526/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641526/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>shell</category><category>tips</category><category>tech</category><category>grep</category><category>tab</category><pubDate>Tue, 18 May 2010 14:48:18 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2010/05/grep-tab.html#comments</comments><guid isPermaLink="false">http://xerr.net/2010/05/grep-tab.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>Nginx模块中调用ngx_localtime()可能死锁</title><link>http://xerr.net/2010/03/nginx_localtime_deadlock.html</link><content:encoded>&lt;p&gt;如果设定了&lt;code&gt;&lt;a href=&quot;http://wiki.nginx.org/NginxHttpMainModule#timer_resolution&quot; target=&quot;_blank&quot;&gt;timer_resolution&lt;/a&gt;&lt;/code&gt;并在自己的模块中调用了&lt;code&gt;ngx_localtime()&lt;/code&gt;，&lt;code&gt;nginx&lt;/code&gt;极有可能失去响应。&lt;/p&gt;
&lt;p&gt;原因看来是&lt;code&gt;localtime_r(3)&lt;/code&gt;信号不安全。&lt;code&gt;nginx&lt;/code&gt;内部会用&lt;code&gt;ngx_time&lt;/code&gt;这个变量中存下当前的时间，默认是在每次&lt;code&gt;event&lt;/code&gt;循环中更新这个变量，减少&lt;code&gt;gettimeofday(2)&lt;/code&gt;的调用次数。设置&lt;code&gt;timer_resolution&lt;/code&gt;参数会导致&lt;code&gt;nginx&lt;/code&gt;使用&lt;code&gt;SIGALRM&lt;/code&gt;信号来定时更新，作者认为这样会有更好的精度。触发信号处理函数&lt;code&gt;ngx_timer_signal_handler()&lt;/code&gt;后，里面调用&lt;code&gt;ngx_localtime()&lt;/code&gt;，最后落实到&lt;code&gt;glibc&lt;/code&gt;的&lt;code&gt;localtime_r(3)&lt;/code&gt;。由于&lt;code&gt;localtime_r(3)&lt;/code&gt;信号不安全，这样自己的模块代码中也进行了&lt;code&gt;ngx_localtime()&lt;/code&gt;调用的话，两者很容易冲突而死锁（不知道我说清楚了吗）。 &lt;/p&gt;
&lt;p&gt;这个问题看起来也没什么好修正的，不要在自己的模块里面用&lt;code&gt;ngx_localtime&lt;/code&gt;()就好了。如果不需要设定&lt;code&gt;timer_resolution&lt;/code&gt;，可以假装一切都很正常。我现在使用&lt;code&gt;ngx_timeofday()/ngx_gmtime()&lt;/code&gt;来格式化时间，目前情绪稳定。&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: nginx 0.7.66 已经修正了此问题。&lt;/p&gt;
&lt;p&gt;参考: &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;讨论链接: &lt;a href=&quot;http://forum.nginx.org/read.php?2,59851&quot;&gt;http://forum.nginx.org/read.php?2,59851&lt;/a&gt;(请无视某人的蹩脚英语) &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://blogs.inxsasia.com/hiran/2009/07/stupid-futex-and-glibc.html&quot;&gt;http://blogs.inxsasia.com/hiran/2009/07/stupid-futex-and-glibc.html&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=301511&quot;&gt;http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=301511&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;ps: 为了这篇post，山寨了个在Windows Live Writer里面给选定文字加&lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt;标签的插件，有需要的同学吗……&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641527/whoisme/feedsky/s.gif?r=http://xerr.net/2010/03/nginx_localtime_deadlock.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641527/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641527/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641527/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641527/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2010/03/nginx_localtime_deadlock.html/feed</wfw:commentRss><slash:comments>1</slash:comments><fs:srclink>http://xerr.net/2010/03/nginx_localtime_deadlock.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641527/5453343</fs:itemid><description>如果设定了timer_resolution并在自己的模块中调用了ngx_localtime()，nginx极有可能失去响应。 原因看来是localtime_r(3)信号不安全。nginx内部会用ngx_time这个变量中存下当前的时间，默认是在每次event循环中更新这个变量，减少gettimeofday(2)的调用次数。设置timer_resolution参数会导致nginx使用SIGALRM信号来定时更新，作者认为这样会有更好的精度。触发信号处理函数ngx_timer_signal_handler()后，里面调用ngx_localtime()，最后落实到glibc的localtime_r(3)。由于localtime_r(3)信号不安全，这样自己的模块代码中也进行了ngx_localtime()调用的话，两者很容易冲突而死锁（不知道我说清楚了吗）。 这个问题看起来也没什么好修正的，不要在自己的模块里面用ngx_localtime()就好了。如果不需要设定timer_resolution，可以假装一切都很正常。我现在使用ngx_timeofday()/ngx_gmtime()来格式化时间，目前情绪稳定。 Update: nginx 0.7.66 已经修正了此问题。 参考: 讨论链接: http://forum.nginx.org/read.php?2,59851(请无视某人的蹩脚英语) http://blogs.inxsasia.com/hiran/2009/07/stupid-futex-and-glibc.html http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=301511 ps: 为了这篇post，山寨了个在Windows Live Writer里面给选定文字加&amp;#60;code&amp;#62;标签的插件，有需要的同学吗……&lt;img src=&quot;http://www1.feedsky.com/t1/407641527/whoisme/feedsky/s.gif?r=http://xerr.net/2010/03/nginx_localtime_deadlock.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641527/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641527/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641527/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641527/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>模块开发</category><category>nginx</category><category>tech</category><category>timer_resolution</category><category>module</category><category>dev</category><category>webserver</category><pubDate>Fri, 19 Mar 2010 19:03:57 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2010/03/nginx_localtime_deadlock.html#comments</comments><guid isPermaLink="false">http://xerr.net/2010/03/nginx_localtime_deadlock.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>当前窗口最小化的快捷键</title><link>http://xerr.net/2010/01/minimize-current-window-hotkey.html</link><content:encoded>&lt;p&gt;Windows 下面有最小化所有窗口的&lt;a href=&quot;http://support.microsoft.com/kb/126449&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;快捷键&lt;/a&gt;, 但默认没有最小化当前窗口的快捷键. 解决方法(之一)是使用仅&lt;code&gt;16.5k&lt;/code&gt;的神器 &lt;a href=&quot;http://www.bcheck.net/apps/hoe.htm&quot; target=&quot;_blank&quot;&gt;HoeKey&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;安装运行 HoeKey 后, 按&lt;code&gt;Win+Q&lt;/code&gt;呼出配置界面, 选择编辑配置文件, 加入一条:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;~0=Msg||274|61472&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;这样就可以用快捷键 &lt;code&gt;Win+0&lt;/code&gt; 来最小化当前窗口了. &lt;/p&gt;
&lt;p&gt;同理可以写 &lt;code&gt;~9=Msg||274|61488&lt;/code&gt; 来用 &lt;code&gt;Win+9&lt;/code&gt; 最大化当前窗口.&lt;/p&gt;
&lt;p&gt;更多自定义触发快捷键以及 HoeKey 功能, 见&lt;a href=&quot;http://www.bcheck.net/apps/hoekey.htm&quot; target=&quot;_blank&quot;&gt;帮助文档&lt;/a&gt;以及&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ms646360(VS.85).aspx&quot; target=&quot;_blank&quot;&gt;MSDN&lt;/a&gt;.&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641528/whoisme/feedsky/s.gif?r=http://xerr.net/2010/01/minimize-current-window-hotkey.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641528/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641528/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641528/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641528/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2010/01/minimize-current-window-hotkey.html/feed</wfw:commentRss><slash:comments>4</slash:comments><fs:srclink>http://xerr.net/2010/01/minimize-current-window-hotkey.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641528/5453343</fs:itemid><description>Windows 下面有最小化所有窗口的快捷键, 但默认没有最小化当前窗口的快捷键. 解决方法(之一)是使用仅16.5k的神器 HoeKey. 安装运行 HoeKey 后, 按Win+Q呼出配置界面, 选择编辑配置文件, 加入一条: ~0=Msg&amp;#124;&amp;#124;274&amp;#124;61472 这样就可以用快捷键 Win+0 来最小化当前窗口了. 同理可以写 ~9=Msg&amp;#124;&amp;#124;274&amp;#124;61488 来用 Win+9 最大化当前窗口. 更多自定义触发快捷键以及 HoeKey 功能, 见帮助文档以及MSDN.&lt;img src=&quot;http://www1.feedsky.com/t1/407641528/whoisme/feedsky/s.gif?r=http://xerr.net/2010/01/minimize-current-window-hotkey.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641528/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641528/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641528/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641528/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>minimize</category><category>tips</category><category>hotkey</category><category>tech</category><category>hoekey</category><category>window</category><category>shortcut</category><pubDate>Mon, 04 Jan 2010 11:45:00 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2010/01/minimize-current-window-hotkey.html#comments</comments><guid isPermaLink="false">http://xerr.net/2010/01/minimize-current-window-hotcut.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>Lighttpd覆盖设置http头</title><link>http://xerr.net/2009/12/lighttpd-set-header.html</link><content:encoded>&lt;p&gt;lighty 1.4 的 setenv 模块是可以操作 http 头的, 但它提供的&lt;a href=&quot;http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ModSetEnv#Options&quot; target=&quot;_blank&quot;&gt;三个指令&lt;/a&gt;实际只是把给定的值附加进去, 如果处理的请求本来有同名的头, 会变成这样:     &lt;br /&gt;&lt;code&gt;Host: foo.com, bar.com &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;对 &lt;code&gt;X_FORWARD_FOR&lt;/code&gt; 这样的头可以如此处理, 但 &lt;code&gt;Host&lt;/code&gt; 之类就不是希望的结果了.比如作为代理时, 伺服的主机名和后端伺服的不同, 需要覆盖掉 &lt;code&gt;Host&lt;/code&gt; 头.&lt;/p&gt;
&lt;p&gt;lighty 1.5 和 nginx 都提供了对应的指令, 1.4 下面得自助. &lt;a href=&quot;http://redmine.lighttpd.net/attachments/946/mod_setenv.c.patch&quot; target=&quot;_blank&quot;&gt;这里&lt;/a&gt;我添加了一个 &lt;code&gt;set-request-header&lt;/code&gt; 指令, 顾名思义(&lt;code&gt;set vs add&lt;/code&gt;), 会用给定值覆盖设置请求头的值. 响应头的因为我用不到所以没实现, 需要的同学自己折腾吧. &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://redmine.lighttpd.net/boards/3/topics/1569&quot; target=&quot;_blank&quot;&gt;patch&lt;/a&gt; 放在 lighty 的论坛上, 但几个月了没人理, 是没人需要鹰语太烂还是要开 issue 才行?&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641529/whoisme/feedsky/s.gif?r=http://xerr.net/2009/12/lighttpd-set-header.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641529/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641529/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641529/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641529/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2009/12/lighttpd-set-header.html/feed</wfw:commentRss><slash:comments>2</slash:comments><fs:srclink>http://xerr.net/2009/12/lighttpd-set-header.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641529/5453343</fs:itemid><description>lighty 1.4 的 setenv 模块是可以操作 http 头的, 但它提供的三个指令实际只是把给定的值附加进去, 如果处理的请求本来有同名的头, 会变成这样: Host: foo.com, bar.com 对 X_FORWARD_FOR 这样的头可以如此处理, 但 Host 之类就不是希望的结果了.比如作为代理时, 伺服的主机名和后端伺服的不同, 需要覆盖掉 Host 头. lighty 1.5 和 nginx 都提供了对应的指令, 1.4 下面得自助. 这里我添加了一个 set-request-header 指令, 顾名思义(set vs add), 会用给定值覆盖设置请求头的值. 响应头的因为我用不到所以没实现, 需要的同学自己折腾吧. patch 放在 lighty 的论坛上, 但几个月了没人理, 是没人需要鹰语太烂还是要开 issue 才行?&lt;img src=&quot;http://www1.feedsky.com/t1/407641529/whoisme/feedsky/s.gif?r=http://xerr.net/2009/12/lighttpd-set-header.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641529/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641529/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641529/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641529/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>模块开发</category><category>header</category><category>http</category><category>tech</category><category>lighttpd</category><category>lighty</category><category>module</category><category>dev</category><category>webserver</category><category>set</category><pubDate>Sun, 06 Dec 2009 09:25:00 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2009/12/lighttpd-set-header.html#comments</comments><guid isPermaLink="false">http://xerr.net/2009/12/lighttpd-set-header.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>终于红了！</title><link>http://xerr.net/2009/11/oiegg-ad-by-gov.html</link><content:encoded>&lt;p&gt;&lt;a title=&quot;2009-11-12_190352&quot; href=&quot;http://www.flickr.com/photos/92146201@N00/4097312705/&quot;&gt;&lt;img alt=&quot;2009-11-12_190352&quot; src=&quot;http://static.flickr.com/2784/4097312705_7e01abf8b9.jpg&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.baidu.com/s?wd=%B9%E3%B5%E7%D7%DC%BE%D6%B9%D8%B1%D5111%BC%D2%CE%DE%D6%A4%CA%D3%CC%FD%BD%DA%C4%BF%B7%FE%CE%F1%CD%F8%D5%BE&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;来源链接&lt;/a&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641530/whoisme/feedsky/s.gif?r=http://xerr.net/2009/11/oiegg-ad-by-gov.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641530/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641530/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641530/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641530/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2009/11/oiegg-ad-by-gov.html/feed</wfw:commentRss><slash:comments>4</slash:comments><fs:srclink>http://xerr.net/2009/11/oiegg-ad-by-gov.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641530/5453343</fs:itemid><description>来源链接&lt;img src=&quot;http://www1.feedsky.com/t1/407641530/whoisme/feedsky/s.gif?r=http://xerr.net/2009/11/oiegg-ad-by-gov.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641530/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641530/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641530/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641530/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>oiegg</category><category>life</category><pubDate>Thu, 12 Nov 2009 19:08:58 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2009/11/oiegg-ad-by-gov.html#comments</comments><guid isPermaLink="false">http://xerr.net/2009/11/oiegg-ad-by-gov.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>Fiddler中显示当前连接的主机地址</title><link>http://xerr.net/2009/11/fiddler-show-host-ip.html</link><content:encoded>&lt;p&gt;我(曾经)觉得 HttpWatch 比 Fiddler 强的一处是，可以显示当前 http 会话中对话主机地址。其实 &lt;a href=&quot;http://www.fiddler2.com&quot; target=&quot;_blank&quot;&gt;Fiddler&lt;/a&gt; 也早就可以了，而且更强大。&lt;a href=&quot;http://groups.google.com/group/httpfiddler/browse_thread/thread/40b92a7580c0e6e1&quot; target=&quot;_blank&quot;&gt;方法&lt;/a&gt;是点菜单的&lt;code&gt;Rules &amp;gt; Customize Rules&lt;/code&gt;，找到并修改文件中的&lt;code&gt;Main()&lt;/code&gt;部份：&lt;/p&gt;
&lt;p&gt;&lt;code&gt;static function Main()      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; FiddlerObject.UI.lvSessions.AddBoundColumn(&amp;quot;HostIP&amp;quot;, 50, &amp;quot;x-       &lt;br /&gt;hostIP&amp;quot;);       &lt;br /&gt;} &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Fiddler 的订制能力挺强，参考&lt;a href=&quot;http://www.fiddler2.com/Fiddler/help/configurecolumns.asp&quot; target=&quot;_blank&quot;&gt;它的文档&lt;/a&gt;可以加入很多元素。它的作者人很好，&lt;a href=&quot;http://groups.google.com/group/httpfiddler/&quot; target=&quot;_blank&quot;&gt;论坛&lt;/a&gt;里面帖子回复很及时。&lt;/p&gt;
&lt;p&gt;另外，由于 .NET 中&lt;code&gt;DNS.Resolve()&lt;/code&gt;不会进行缓存，所以在 Fiddler 代理时对 hosts 文件的修改可以即时生效。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641531/whoisme/feedsky/s.gif?r=http://xerr.net/2009/11/fiddler-show-host-ip.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641531/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641531/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641531/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641531/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2009/11/fiddler-show-host-ip.html/feed</wfw:commentRss><slash:comments>6</slash:comments><fs:srclink>http://xerr.net/2009/11/fiddler-show-host-ip.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641531/5453343</fs:itemid><description>我(曾经)觉得 HttpWatch 比 Fiddler 强的一处是，可以显示当前 http 会话中对话主机地址。其实 Fiddler 也早就可以了，而且更强大。方法是点菜单的Rules &amp;#62; Customize Rules，找到并修改文件中的Main()部份： static function Main() { &amp;#160;&amp;#160;&amp;#160; FiddlerObject.UI.lvSessions.AddBoundColumn(&amp;#34;HostIP&amp;#34;, 50, &amp;#34;x- hostIP&amp;#34;); } Fiddler 的订制能力挺强，参考它的文档可以加入很多元素。它的作者人很好，论坛里面帖子回复很及时。 另外，由于 .NET 中DNS.Resolve()不会进行缓存，所以在 Fiddler 代理时对 hosts 文件的修改可以即时生效。&lt;img src=&quot;http://www1.feedsky.com/t1/407641531/whoisme/feedsky/s.gif?r=http://xerr.net/2009/11/fiddler-show-host-ip.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641531/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641531/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641531/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641531/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>fildder</category><category>http</category><category>tech</category><category>dev</category><pubDate>Mon, 09 Nov 2009 14:52:24 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2009/11/fiddler-show-host-ip.html#comments</comments><guid isPermaLink="false">http://xerr.net/2009/11/fiddler-show-host-ip.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>周末就这样过去了</title><link>http://xerr.net/2009/11/cold-rain-snow-weekend.html</link><content:encoded>&lt;p&gt;周五晚上骑车去中关村，半路上开始下雨，就在冷雨里面骑了一转。&lt;/p&gt;
&lt;p&gt;周六晚上骑车去师大吃饭，到了就开始下，更冷的雨，再次被浇。&lt;/p&gt;
&lt;p&gt;只好留宿。躺半天睡不着，拿出手机，弄了两下，没电了。&lt;/p&gt;
&lt;p&gt;周日早上醒来，发现外边下大雪。。。那个大呦，手指头插积雪里到不了底。&lt;/p&gt;
&lt;p&gt;索性迎着风雪骑回去。我是年轻人阿！&lt;/p&gt;
&lt;p&gt;我一会儿往西骑，雪迎着我下。一会儿往北骑，雪迎着我下。一会儿往东骑，雪迎着我下。路上好像就我一个&lt;del&gt;瓜&lt;/del&gt;人在骑骑骑，好拉风的。&lt;/p&gt;
&lt;p&gt;然后到家，一下雪就停了。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641532/whoisme/feedsky/s.gif?r=http://xerr.net/2009/11/cold-rain-snow-weekend.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641532/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641532/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641532/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641532/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2009/11/cold-rain-snow-weekend.html/feed</wfw:commentRss><slash:comments>10</slash:comments><fs:srclink>http://xerr.net/2009/11/cold-rain-snow-weekend.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641532/5453343</fs:itemid><description>周五晚上骑车去中关村，半路上开始下雨，就在冷雨里面骑了一转。 周六晚上骑车去师大吃饭，到了就开始下，更冷的雨，再次被浇。 只好留宿。躺半天睡不着，拿出手机，弄了两下，没电了。 周日早上醒来，发现外边下大雪。。。那个大呦，手指头插积雪里到不了底。 索性迎着风雪骑回去。我是年轻人阿！ 我一会儿往西骑，雪迎着我下。一会儿往北骑，雪迎着我下。一会儿往东骑，雪迎着我下。路上好像就我一个瓜人在骑骑骑，好拉风的。 然后到家，一下雪就停了。&lt;img src=&quot;http://www1.feedsky.com/t1/407641532/whoisme/feedsky/s.gif?r=http://xerr.net/2009/11/cold-rain-snow-weekend.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641532/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641532/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641532/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641532/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>life</category><pubDate>Sun, 01 Nov 2009 18:49:45 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2009/11/cold-rain-snow-weekend.html#comments</comments><guid isPermaLink="false">http://xerr.net/2009/11/cold-rain-snow-weekend.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>不小心喝多了就是会手肘酸</title><link>http://xerr.net/2009/10/drank-too-much.html</link><content:encoded>&lt;p&gt;和&lt;del&gt;怀疑人生&lt;/del&gt;夜里醒来。&lt;br /&gt;
年底又有人要&lt;del&gt;结婚&lt;/del&gt;订婚啊，怎么怎么这么快。&lt;br /&gt;
或者是我太慢。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641533/whoisme/feedsky/s.gif?r=http://xerr.net/2009/10/drank-too-much.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641533/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641533/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641533/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641533/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2009/10/drank-too-much.html/feed</wfw:commentRss><slash:comments>8</slash:comments><fs:srclink>http://xerr.net/2009/10/drank-too-much.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641533/5453343</fs:itemid><description>和怀疑人生夜里醒来。 年底又有人要结婚订婚啊，怎么怎么这么快。 或者是我太慢。&lt;img src=&quot;http://www1.feedsky.com/t1/407641533/whoisme/feedsky/s.gif?r=http://xerr.net/2009/10/drank-too-much.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641533/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641533/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641533/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641533/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>life</category><pubDate>Sat, 03 Oct 2009 05:53:35 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2009/10/drank-too-much.html#comments</comments><guid isPermaLink="false">http://xerr.net/?p=117</guid><dc:creator>georgexsh</dc:creator></item><item><title>Nginx模块开发小记</title><link>http://xerr.net/2009/09/nginx-module-dev.html</link><content:encoded>&lt;p&gt;前阵子在折腾Nginx的模块, 很有趣.&lt;/p&gt;
&lt;p&gt;为了方便使用调试器, 可以单进程非daemon方式启动, 使用参数:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;daemon off;      &lt;br /&gt;master_process&amp;#160; off; &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;因为Nginx是事件驱动, 在读request body时, 第一个数据包一般发送不全, 需要异步读取余下的.&lt;/p&gt;
&lt;p&gt;当在主handler部分调用ngx_http_read_client_request_body时, 需要注册一个回调的handler, 然后主handler直接返回NGX_DONE, 告诉Nginx留下这个请求的事件注册, 继续接收数据包.&lt;/p&gt;
&lt;p&gt;经过若干次循环最终读完request body后, Nginx会去回调被注册的handler, 在此函数中产生响应, 最后调用ngx_http_finalize_request结束整个请求. 大概流程是: &lt;/p&gt;
&lt;p&gt;&lt;code&gt;ngx_http_foo_handler(){      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ngx_http_read_client_request_body(r, ngx_http_foo_post_handler);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return NGX_DONE; // 主handler结束       &lt;br /&gt;}       &lt;br /&gt;ngx_http_foo_post_handler(){       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // 请求全部读完后从这里入口, 可以产生响应       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; ngx_http_finalize_request(r, NGX_HTTP_OK);       &lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;一般的模块都是同步方式的, 我开始就没搞明白这异步读到底怎么搞, 走了不少弯路. 代码上可以简单参考&lt;a href=&quot;http://www.evanmiller.org/lxr/http/source/http/modules/ngx_http_dav_module.c#L164&quot; target=&quot;_blank&quot;&gt;dav模块&lt;/a&gt;, 复杂点还有&lt;a href=&quot;http://www.grid.net.ru/nginx/upload.en.html&quot; target=&quot;_blank&quot;&gt;upload模块&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Nginx可能会把request body放到两个buffer里面, 太大的话也可能存入文件中. 如果要在模块中读取request body进行处理, 自然不希望搞太麻烦,可以: &lt;/p&gt;
&lt;p&gt;&lt;code&gt;r-&amp;gt;request_body_in_single_buf = 1;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;使body存在一个buffer里面, 配置里面要留够需要的大小.&lt;/p&gt;
&lt;p&gt;如果没有特殊的要求, 这类模块也可以拿 &lt;a href=&quot;http://wiki.nginx.org/NginxEmbeddedPerlModule&quot; target=&quot;_blank&quot;&gt;embedded perl&lt;/a&gt; 来写. 响应产生, sendfile都支持. Perl的开发效率自然很高, 维护也方便. 作者说此功能还是&amp;quot;experimental&amp;quot;,&amp;#160; 但实测了下没出啥问题.&lt;/p&gt;
&lt;p&gt;我本着先写原型的目的试验了下, 结果发现性能还不错, 在双路5130机器上, perl版本的可以达到15k req/s (使用ab测试), 非常够用了.&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407641534/whoisme/feedsky/s.gif?r=http://xerr.net/2009/09/nginx-module-dev.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641534/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641534/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641534/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641534/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://xerr.net/2009/09/nginx-module-dev.html/feed</wfw:commentRss><slash:comments>2</slash:comments><fs:srclink>http://xerr.net/2009/09/nginx-module-dev.html</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407641534/5453343</fs:itemid><description>前阵子在折腾Nginx的模块, 很有趣. 为了方便使用调试器, 可以单进程非daemon方式启动, 使用参数: daemon off; master_process&amp;#160; off; 因为Nginx是事件驱动, 在读request body时, 第一个数据包一般发送不全, 需要异步读取余下的. 当在主handler部分调用ngx_http_read_client_request_body时, 需要注册一个回调的handler, 然后主handler直接返回NGX_DONE, 告诉Nginx留下这个请求的事件注册, 继续接收数据包. 经过若干次循环最终读完request body后, Nginx会去回调被注册的handler, 在此函数中产生响应, 最后调用ngx_http_finalize_request结束整个请求. 大概流程是: ngx_http_foo_handler(){ &amp;#160;&amp;#160;&amp;#160; ngx_http_read_client_request_body(r, ngx_http_foo_post_handler); &amp;#160;&amp;#160;&amp;#160; return NGX_DONE; // 主handler结束 } ngx_http_foo_post_handler(){ &amp;#160;&amp;#160;&amp;#160; // 请求全部读完后从这里入口, 可以产生响应 &amp;#160;&amp;#160;&amp;#160; ngx_http_finalize_request(r, NGX_HTTP_OK); } 一般的模块都是同步方式的, 我开始就没搞明白这异步读到底怎么搞, 走了不少弯路. 代码上可以简单参考dav模块, 复杂点还有upload模块. Nginx可能会把request body放到两个buffer里面, 太大的话也可能存入文件中. 如果要在模块中读取request body进行处理, 自然不希望搞太麻烦,可以: [...]&lt;img src=&quot;http://www1.feedsky.com/t1/407641534/whoisme/feedsky/s.gif?r=http://xerr.net/2009/09/nginx-module-dev.html&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641534/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641534/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407641534/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407641534/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>模块开发</category><category>nginx</category><category>tech</category><category>perl</category><category>module</category><category>dev</category><category>webserver</category><pubDate>Fri, 04 Sep 2009 00:53:07 +0800</pubDate><author>georgexsh</author><comments>http://xerr.net/2009/09/nginx-module-dev.html#comments</comments><guid isPermaLink="false">http://xerr.net/2009/09/nginx-module-dev.html</guid><dc:creator>georgexsh</dc:creator></item><item><title>del.icio.us [2009-08-24]:georgexsh @ del.icio.us</title><link>http://www.delicious.com/georgexsh#2009-08-24</link><fs:burntype>mark day</fs:burntype><fs:srclink>http://www.delicious.com/georgexsh#2009-08-24</fs:srclink><fs:srcfeed>http://xerr.net/feed</fs:srcfeed><fs:itemid>feedsky/whoisme/~7343819/407928223/5453343</fs:itemid><description>&lt;ul&gt;&lt;li&gt;&lt;a href='http://www.sleepingchinese.com/' title='link to ..'&gt;www.sleepingchinese.com - Welcome&lt;/a&gt;&lt;br/&gt;&lt;div&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/407928223/whoisme/feedsky/s.gif?r=http://www.delicious.com/georgexsh#2009-08-24&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/whoisme/407928223/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/whoisme/407928223/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><pubDate>Mon, 24 Aug 2009 00:00:00 +0800</pubDate><guid isPermaLink="false">http://www.delicious.com/georgexsh#2009-08-24</guid></item></channel></rss>