摘要:
大家好,今天继续上一篇没讲完的mochiweb_request:not_found/1函数:%% @spec not_found(ExtraHeaders) -> response()%% @doc Alias for <code>respond({404, [{"Content-Type", "text/plain"}%% | ExtraHeaders], <<"Not found.">>})</code>.not_found(ExtraHeade 阅读全文
随笔档案-2012年08月
mochiweb 源码阅读(十九)
2012-08-23 00:10 by rhinovirus, 1799 阅读, 收藏,
摘要:
大家好,好几天没跟新了,今天继续来和大家分享mochiweb源码,上一篇,我们看到了mochiweb_request:get(path)分支,这一篇我们依然回到mochiweb_example_web:loop/2继续往下:loop(Req, DocRoot) -> "/" ++ Path = Req:get(path), try case Req:get(method) of Method when Method =:= 'GET'; Method =:= 'HEAD' -> case Path of ... 阅读全文
mochiweb 源码阅读(十八)
2012-08-14 00:07 by rhinovirus, 2120 阅读, 收藏,
摘要:
大家好,这两天简单测试了下 erlang-mysql-driver,erlang-mysql-driver 是 MySQL 的 Erlang 语言驱动程序。代码可通过 SVN 获取: svn checkout http://erlang-mysql-driver.googlecode.com/svn/trunk/ erlang-mysql-driver-read-only 以后再分享给大家,今天继续来看mochiweb源码,依然是看下面几行: {Protocol, _, http_eoh} when Protocol == http orelse Protocol == ... 阅读全文
mochiweb 源码阅读(十七)
2012-08-11 02:37 by rhinovirus, 2048 阅读, 收藏,
摘要:
大家好,今天周五,继续来和大家一起分享mochiweb源码。最近我也是在看百度连城翻译的《Erlang/OTP并发编程实战》,其中第11章:为缓存添加HTTP接口,有这本书的朋友可以翻看下,这里介绍的内容,有助于大家理解mochiweb源码。 上一篇,我们讲到了mochiweb_http:headers/5函数,当所有协议头解析完毕后会有一个空行,它标志着报文头部的结束,剩下的便是消息正文。 {Protocol, _, http_eoh} when Protocol == http orelse Protocol == ssl -> Req = new... 阅读全文
mochiweb 源码阅读(十六)
2012-08-06 23:57 by rhinovirus, 1762 阅读, 收藏,
摘要:
大家好,几天没跟新这个系列了,忙着考驾照,今天继续来跟大家分享mochiweb源码,上一篇我们讲到了mochiweb_http:handle_invalid_request/1函数,这一篇,我们来看下,正确的逻辑处理,再讲这之前,还有个地方跟大家提下,就是如果mochiweb_http:request/2函数,在使用receive读取消息时,如果发生超时,则是简单的关闭套接字以及退出进程,代码如下: after ?REQUEST_RECV_TIMEOUT -> mochiweb_socket:close(Socket), exit(normal) e... 阅读全文
Ubuntu 下 libev编译安装
2012-08-06 21:04 by rhinovirus, 6233 阅读, 收藏,
摘要:
下载源码,以及编译安装: cvs -z3 -d :pserver:anonymous@cvs.schmorp.de/schmorpforge co libev sh autogen.sh ./configure && make sudo make install 阅读全文
mochiweb 源码阅读(十五)
2012-08-03 00:54 by rhinovirus, 2001 阅读, 收藏,
摘要:
大家好,这一篇我们接着上一篇最后提到的mochiweb_http:request/2继续来和大家分享mochiweb源码:request(Socket, Body) -> ok = mochiweb_socket:setopts(Socket, [{active, once}]), receive {Protocol, _, {http_request, Method, Path, Version}} when Protocol == http orelse Protocol == ssl -> ok = mochiweb_socket:se... 阅读全文
mochiweb 源码阅读(十四)
2012-08-01 00:43 by rhinovirus, 1754 阅读, 收藏,
摘要:
大家好,下了一天雨,十分凉爽,继续来看mochiweb源码,这一篇,我们来消化下上一篇留下的问题。 首先是mochiweb_socket_server:handle_cast/2关于{accepted, Pid, Timing}消息的处理:handle_cast({accepted, Pid, Timing}, State=#mochiweb_socket_server{active_sockets=ActiveSockets}) -> State1 = State#mochiweb_socket_server{active_sockets=1 + Activ... 阅读全文
浙公网安备 33010602011771号