Created
February 7, 2012 16:39
-
-
Save majek/1760599 to your computer and use it in GitHub Desktop.
cowboy http/1.0 bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env escript | |
%%! -smp disable +A1 +K true -pz ./ebin -pa deps/cowboy/ebin -input | |
-module(cowboy_http10_bug). | |
-mode(compile). | |
-export([main/1]). | |
%% Cowboy callbacks | |
-export([init/3, handle/2, terminate/2]). | |
main(_) -> | |
Port = 9999, | |
application:start(cowboy), | |
VhostRoutes = [{'_', ?MODULE, []}], | |
Routes = [{'_', VhostRoutes}], | |
cowboy:start_listener(http, 100, | |
cowboy_tcp_transport, [{port, Port}], | |
cowboy_http_protocol, [{dispatch, Routes}]), | |
io:format(" [*] Running at http://localhost:~p~n", [Port]), | |
receive | |
_ -> ok | |
end. | |
%% -------------------------------------------------------------------------- | |
init({_Any, http}, Req, []) -> | |
{ok, Req, []}. | |
handle(Req, State) -> | |
{ok, Req1} = cowboy_http_req:chunked_reply(200, [], Req), | |
_ = cowboy_http_req:chunk(<<"ok">>, Req1), | |
{ok, Req1, State}. | |
terminate(_Req, _State) -> | |
ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /blah HTTP/1.0 | |
Host: localhost:9999 | |
Accept-Encoding: identity | |
Content-Length: 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment