Skip to content

Commit 6ea9f14

Browse files
committed
Changes to maintain compatibility with latest updates in Cowboy
1 parent af675e0 commit 6ea9f14

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
charreada
22
=========
33

4-
Simple Erlang reverse proxy leveraging Cowboy
4+
Simple Erlang reverse proxy leveraging Cowboy and iBrowse.
5+

src/charreada.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
start_http_proxy(NbAcceptors, TransOpts, Timeout) ->
88
Dispatch = [{'_', [ {'_', charreada_handler, []} ]} ],
99
Fun = fun(Req) -> charreada_handler:onrequest(Req, Timeout) end,
10-
ProtoOpts = [ {dispatch, Dispatch}, {onrequest, Fun} ],
10+
ProtoOpts = [ {env, [{dispatch, Dispatch}]}, {onrequest, Fun} ],
1111
{ok, _} = cowboy:start_http(http, NbAcceptors, TransOpts, ProtoOpts),
1212
ok.
1313

src/charreada_handler.erl

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ info({ibrowse_get_body, Pid}, Req, State) ->
3737
stream(cowboy_req:stream_body(Req), Req, Pid, State);
3838
info({ibrowse_async_headers, RequestId, Code, HeadersOrg}, Req, {Timeout, undefined}) ->
3939
{Headers, Length} = process_headers(HeadersOrg, [], 0),
40-
{ok, Transport, Socket} = cowboy_req:transport(Req),
41-
Fun = fun() -> stream_reply({RequestId, Transport, Socket, Length}, Length) end,
40+
Fun =
41+
fun(Socket, Transport) ->
42+
stream_reply({RequestId, Transport, Socket, Length}, Length)
43+
end,
4244
{ok, ReplyReq} = cowboy_req:reply(list_to_integer(Code), Headers, {Length, Fun}, Req),
4345
{loop, ReplyReq, {Timeout, Length}};
4446
info({ibrowse_async_response, _RequestId, []}, Req, State) ->

0 commit comments

Comments
 (0)