1
我在学习erlang,下面是解释如何使用gen_tcp的一个例子的一部分。然而,几乎所有的toturials都会向你显示echo服务器,我没有发现任何真正的世界http请求解析。erlang如何解析一个http请求?
handle_connect(Socket, BinaryList, Count) ->
io:format("handle_connect ~p~n", [self()]),
case gen_tcp:recv(Socket, 0) of
{ok, Binary} ->
io:format("request is :~s~n", Binary),
case gen_tcp:send(Socket, Binary) of
ok ->
handle_connect(Socket, BinaryList, Count);
{error, Reason} ->
io:format("send failed~n"),
gen_tcp:close(Socket)
end;
我很好奇erlang如何解析收到的数据gen_tcp:recv
。我已经通过lib/inets-5.7.1/src/http_server
下的一些代码进行了浏览,但是有太多的模块,我仍然无法弄清楚解析http请求的基本方向。任何人都可以告诉我如何解析http请求,以及那些web框架采取的方法是什么。谢谢〜