-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
Description
Some times i need to auto receive request body. For example for getting vars from "/login" POST request.
And also i need to upload big files on server and save it in special folder. (Big means > 100MB).
In this cases i need to have different post_max_size. And in first case i need to allow auto_recv_body.
Here is a part of sample code.
start(Port) ->
misultin:start_link([{port, Port}, {auto_recv_body, false}, {loop, fun(Req) -> handle_http(Req) end}]).
stop() ->
misultin:stop().
handle_http(Req) ->
handle(Req:get(method), Req:resource([lowercase, urldecode]), Req).
handle('GET',["login"],Req) ->
Req:file("login.html");
handle('POST',["login"],Req) ->
Args = Req:parse_post(),
case Req:get_variable("login",Args) of
undefined ->
Req:ok("Error. You need to login.");
Login ->
Req:ok("Hello, "++Login)
end;
handle('POST',["upload_big_file"],Req) ->
get_body_and_save_to_file(Req).
Every time I try to login using POST-request I get the message "Error. You need to login.".
Do I need to manually load each time the body of the request and process it to get the variables. Or there is a way to use parse_post() ??