~ubuntu-branches/ubuntu/trusty/ejabberd/trusty-proposed

« back to all changes in this revision

Viewing changes to src/web/ejabberd_http_bind.erl

  • Committer: Bazaar Package Importer
  • Author(s): Konstantin Khomoutov, Konstantin Khomoutov, Gerfried Fuchs
  • Date: 2010-04-06 13:00:03 UTC
  • mfrom: (1.1.14 upstream) (13.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100406130003-ub626hx26kgazp79
Tags: 2.1.3-1
[ Konstantin Khomoutov ]
* New upstream release.
* Remove obsolete c2s-p1-fsm.patch
* Remove obsolete ejabberdctl-help-dashes.patch
* Update mod_admin_extra to revision 1078
* Refresh shared_roster_recent.patch
* Refresh shared_roster_online.patch
* Clarify how to do mixed IPv4/IPv6 setup of ejabberd listeners
  as suggested by Marc Dequènes in the discussion of #573801.

[ Gerfried Fuchs ]
* Remove Torsten Werner from maintainer field on his own wish - thanks for
  your work so far! (closes: #578722)
* Promote Konstantin to Maintainer to best fit reality. Enjoy. :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
-include("ejabberd.hrl").
38
38
-include("jlib.hrl").
39
39
-include("ejabberd_http.hrl").
 
40
-include("http_bind.hrl").
40
41
 
41
42
-record(http_bind, {id, pid, to, hold, wait, version}).
42
43
 
100
101
-define(MAX_PAUSE, 120). % may num of sec a client is allowed to pause
101
102
                         % the session
102
103
 
103
 
-define(CT, {"Content-Type", "text/xml; charset=utf-8"}).
104
 
-define(HEADER, [?CT]).
105
 
 
106
104
 
107
105
%%%----------------------------------------------------------------------
108
106
%%% API
177
175
        {ok, {"", Rid, Attrs, Payload}} ->
178
176
            case xml:get_attr_s("to",Attrs) of
179
177
                "" ->
180
 
                    ?ERROR_MSG("Session not created (Improper addressing)", []),
 
178
                    ?DEBUG("Session not created (Improper addressing)", []),
181
179
                    {200, ?HEADER, "<body type='terminate' "
182
180
                     "condition='improper-addressing' "
183
181
                     "xmlns='" ++ ?NS_HTTP_BIND ++ "'/>"};
383
381
    Reply = ok,
384
382
    {stop, normal, Reply, StateData};
385
383
handle_sync_event({stop,Reason}, _From, _StateName, StateData) ->
386
 
    ?ERROR_MSG("Closing bind session ~p - Reason: ~p", [StateData#state.id, Reason]),
 
384
    ?DEBUG("Closing bind session ~p - Reason: ~p", [StateData#state.id, Reason]),
387
385
    Reply = ok,
388
386
    {stop, normal, Reply, StateData};
389
387
 
753
751
              Request, StateName,
754
752
              StateData#state{unprocessed_req_list = NewRequests});
755
753
        _ ->
756
 
            {reply, Reply, StateName, StateData}
 
754
            {reply, Reply, StateName, StateData, hibernate}
757
755
    end.
758
756
 
759
757
handle_http_put(Sid, Rid, Attrs, Payload, PayloadSize, StreamStart, IP) ->
760
758
    case http_put(Sid, Rid, Attrs, Payload, PayloadSize, StreamStart, IP) of
761
759
        {error, not_exists} ->
762
 
            ?ERROR_MSG("no session associated with sid: ~p", [Sid]),
 
760
            ?DEBUG("no session associated with sid: ~p", [Sid]),
763
761
            {404, ?HEADER, ""};
764
762
        {{error, Reason}, Sess} ->
765
 
            ?ERROR_MSG("Error on HTTP put. Reason: ~p", [Reason]),
 
763
            ?DEBUG("Error on HTTP put. Reason: ~p", [Reason]),
766
764
            handle_http_put_error(Reason, Sess);
767
765
        {{repeat, OutPacket}, Sess} ->
768
766
            ?DEBUG("http_put said 'repeat!' ...~nOutPacket: ~p", [OutPacket]),
832
830
    gen_fsm:sync_send_all_state_event(FsmRef,{stop, {put_error_no_version, Reason}}),
833
831
    case Reason of
834
832
        not_exists -> %% bad rid
835
 
            ?ERROR_MSG("Closing HTTP bind session (Bad rid).", []),
 
833
            ?DEBUG("Closing HTTP bind session (Bad rid).", []),
836
834
            {404, ?HEADER, ""};
837
835
        bad_key ->
838
 
            ?ERROR_MSG("Closing HTTP bind session (Bad key).", []),
 
836
            ?DEBUG("Closing HTTP bind session (Bad key).", []),
839
837
            {404, ?HEADER, ""};
840
838
        polling_too_frequently ->
841
 
            ?ERROR_MSG("Closing HTTP bind session (User polling too frequently).", []),
 
839
            ?DEBUG("Closing HTTP bind session (User polling too frequently).", []),
842
840
            {403, ?HEADER, ""}
843
841
    end.
844
842
 
900
898
            ?DEBUG("OutPacket: ~p", [OutPacket]),
901
899
            case StreamStart of
902
900
                false ->
903
 
                    send_outpacket(Sess, OutPacket);
 
901
                    case catch send_outpacket(Sess, OutPacket) of
 
902
                        {'EXIT', _Reason} ->
 
903
                            {200, ?HEADER,
 
904
                             "<body type='terminate' xmlns='"++
 
905
                             ?NS_HTTP_BIND++"'/>"};
 
906
                        SendRes ->
 
907
                            SendRes
 
908
                    end;
904
909
                true ->
905
910
                    case OutPacket of
906
911
                        [{xmlstreamstart, _, OutAttrs} | Els] ->