X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=modules%2Ferl%2Feuphorik_requests.erl;h=28019da95d8be378766e1fd1e5641e45d9ef7656;hp=79df04d53f910e99f1ac700a139433daffa2263a;hb=650c44a784cabc8a1f2bd1daa7e5e61ccf74ca6f;hpb=28cbabecbfc2e05861779a19e5a75bddbc0ad416 diff --git a/modules/erl/euphorik_requests.erl b/modules/erl/euphorik_requests.erl index 79df04d..28019da 100755 --- a/modules/erl/euphorik_requests.erl +++ b/modules/erl/euphorik_requests.erl @@ -1,31 +1,42 @@ % coding: utf-8 +% Copyright 2008 Grégory Burri +% +% This file is part of Euphorik. +% +% Euphorik is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Euphorik is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Euphorik. If not, see . +% % Ce module est fait pour répondre à des requêtes 'AJAX'. % Il est définit comme 'appmods' pour l'url "request" dans yaws. % Par exemple http://www.euphorik.ch/request abouti sur la fonction out() de ce module. % @author G.Burri + -module(euphorik_requests). --export([ - tester/0, - out/1 -]). +-export([out/1]). -include_lib("xmerl/include/xmerl.hrl"). -include_lib("yaws/include/yaws_api.hrl"). -% Test du module (TODO) -tester() -> - que_dal. - - out(A) -> %io:format("~p~n", [A]), % utilisé parfois pendant le debug IP = case inet:peername(A#arg.clisock) of {ok, {Adresse, _Port}} -> Adresse; _ -> inconnue end, - % passive -> active, permet de recevoir {tcp_closed, _} lorsque le socket se ferme - inet:setopts(A#arg.clisock, [{active, true}]), + % passive -> active, permet de recevoir {tcp_closed, _} lorsque le socket se ferme + % keepalive -> true, evite que des firewalls coupe la connexion TCP sans prévenir + inet:setopts(A#arg.clisock, [{active, true}, {keepalive, true}]), {value, {_, Contenu}} = lists:keysearch("action", 1, yaws_api:parse_post(A)), Ret = traiter_donnees(Contenu, IP), {content, "application/json", Ret}.