knutin / elli

Simple, robust and performant Erlang web server
MIT License
663 stars 79 forks source link

elli_http:chunk_loop/1 cannot match message {tcp_closed, Socket} in its receive block #88

Closed zampino closed 7 years ago

zampino commented 9 years ago

Around line https://github.com/knutin/elli/blob/master/src/elli_http.erl#L258 we have

...
chunk_loop(Socket) ->
    receive
        {tcp_closed, Socket} ->
            {error, client_closed};
....

Where Socket is a tuple of type

-type socket() :: {plain, inet:socket()} | {ssl, ssl:sslsocket()}.

but the message being received is of the form { tcp_closed, X:socket()}.

The fix is easy, I can provide a pr.

I found this while sketching an Elixir Plug Adapter for Elli, does anyone knows if an "official" adapter is under development.

Cheers, Andrea

knutin commented 9 years ago

Thanks for catching this! I would be very happy to accept a Pull Request.

There's at least two projects wrapping elli in Elixir, but I don't know anything about development of a plug adapter except what you'll find on Google.

https://github.com/mme/ellihandler https://github.com/pigmej/exelli

zampino commented 9 years ago

Ok, yes I saw exelli. Anyway you have pr #89

CrowdHailer commented 8 years ago

I have been working on an alternative to plug. https://github.com/CrowdHailer/raxx which might be of interest on the subject of elixir adapters for elli.

Currently I have reached an impasse. Is it possible to get arbitrary messages out of the request processes mailbox? the equivalent of a handle_info on the request handler. I have been looking through the source code but can't see any way. I think i need something like the following in the chunk loop

chunk_loop(Socket) ->
    receive
        {tcp_closed, Socket} ->
            {error, client_closed};
        other ->
            Mod.handle_info(other)