jetti777Ltd / mochiweb

Automatically exported from code.google.com/p/mochiweb
Other
0 stars 0 forks source link

Something very, very weird going on in mochiweb_http:request/2 #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I tried running mochiweb with the latest erlang-build R12B-3, because i
wanted to be able to compile docs, and maybe get +native support to work.
Weirdly enough, without the +native flag set, it starts behaving exactly
the same way it did before with +native set:   After the request is sent,
it just closes the tcp connection.
After some debugging i may have come to the root of the problem:  
 the function request/2 in mochiweb_http.erl won't match patterns correctly:

this is the code:
request(Socket, Body) ->
io:format("request 1"),
    case gen_tcp:recv(Socket, 0, ?IDLE_TIMEOUT) of
        {ok, {http_request, Method, Path, Version}} ->
            headers(Socket, {Method, Path, Version}, [], Body);
        {error, {http_error, "\r\n"}} ->
            request(Socket, Body);
        {error, {http_error, "\n"}} ->
            request(Socket, Body);
        _Other ->
            io:format("~nOther = ~p~n", [_Other]),   %my debug line
            gen_tcp:close(Socket),
            exit(normal)
    end.

and this is the output of my debug line:
Other = {ok,{http_request,'GET',{abs_path,"/"},{1,1}}}

this makes absolutely no sense, as this is a perfectly valid match for the
first pattern in the case-of.

I'm very confused :S  Does someone have an explanation ?

Original issue reported on code.google.com by heavyhen...@gmail.com on 8 Aug 2008 at 4:06

GoogleCodeExporter commented 8 years ago
My mistake.. This ONLY happens with +native set.. A bug in HiPE's pattern 
matching
perhaps?

Original comment by heavyhen...@gmail.com on 8 Aug 2008 at 4:20

GoogleCodeExporter commented 8 years ago
Yeah, mochiweb is not currently compatible with HiPE due to HiPE not 
implementing parameterized modules 
correctly.

Original comment by bob.ippo...@gmail.com on 16 Feb 2009 at 6:46