mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Return terminal binding condition on max stanza size limit (thanks to Aleksey)
SVN Revision: 2600
This commit is contained in:
parent
ff1622c658
commit
719aff1088
@ -177,7 +177,7 @@ process_request(Data, IP) ->
|
|||||||
{ok, {"", Rid, Attrs, Payload}} ->
|
{ok, {"", Rid, Attrs, Payload}} ->
|
||||||
case xml:get_attr_s("to",Attrs) of
|
case xml:get_attr_s("to",Attrs) of
|
||||||
"" ->
|
"" ->
|
||||||
?INFO_MSG("Session not created (Improper addressing).~nAttributes: ~p", [Attrs]),
|
?ERROR_MSG("Session not created (Improper addressing)", []),
|
||||||
{200, ?HEADER, "<body type='terminate' "
|
{200, ?HEADER, "<body type='terminate' "
|
||||||
"condition='improper-addressing' "
|
"condition='improper-addressing' "
|
||||||
"xmlns='" ++ ?NS_HTTP_BIND ++ "'/>"};
|
"xmlns='" ++ ?NS_HTTP_BIND ++ "'/>"};
|
||||||
@ -213,8 +213,16 @@ process_request(Data, IP) ->
|
|||||||
end,
|
end,
|
||||||
handle_http_put(Sid, Rid, Attrs, Payload2, PayloadSize,
|
handle_http_put(Sid, Rid, Attrs, Payload2, PayloadSize,
|
||||||
StreamStart, IP);
|
StreamStart, IP);
|
||||||
{error, size_limit} ->
|
{size_limit, Sid} ->
|
||||||
{413, ?HEADER, "Request Too Large"};
|
case mnesia:dirty_read({http_bind, Sid}) of
|
||||||
|
[] ->
|
||||||
|
{404, ?HEADER, ""};
|
||||||
|
[#http_bind{pid = FsmRef}] ->
|
||||||
|
gen_fsm:sync_send_all_state_event(FsmRef, {stop, close}),
|
||||||
|
{200, ?HEADER, "<body type='terminate' "
|
||||||
|
"condition='undefined-condition' "
|
||||||
|
"xmlns='" ++ ?NS_HTTP_BIND ++ "'>Request Too Large</body>"}
|
||||||
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
?DEBUG("Received bad request: ~p", [Data]),
|
?DEBUG("Received bad request: ~p", [Data]),
|
||||||
{400, ?HEADER, ""}
|
{400, ?HEADER, ""}
|
||||||
@ -393,10 +401,10 @@ handle_sync_event(#http_put{rid = Rid},
|
|||||||
?DEBUG("Shaper timer for RID ~p: ~p", [Rid, Reply]),
|
?DEBUG("Shaper timer for RID ~p: ~p", [Rid, Reply]),
|
||||||
{reply, Reply, StateName, StateData};
|
{reply, Reply, StateName, StateData};
|
||||||
|
|
||||||
handle_sync_event(#http_put{rid = _Rid, attrs = _Attrs,
|
handle_sync_event(#http_put{rid = Rid, attrs = Attrs,
|
||||||
payload_size = PayloadSize,
|
payload_size = PayloadSize,
|
||||||
hold = _Hold} = Request,
|
hold = Hold} = Request,
|
||||||
_From, StateName, StateData) ->
|
From, StateName, StateData) ->
|
||||||
?DEBUG("New request: ~p",[Request]),
|
?DEBUG("New request: ~p",[Request]),
|
||||||
%% Updating trafic shaper
|
%% Updating trafic shaper
|
||||||
{NewShaperState, NewShaperTimer} =
|
{NewShaperState, NewShaperTimer} =
|
||||||
@ -1073,10 +1081,7 @@ send_outpacket(#http_bind{pid = FsmRef}, OutPacket) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
parse_request(_Data, PayloadSize, MaxStanzaSize)
|
parse_request(Data, PayloadSize, MaxStanzaSize) ->
|
||||||
when PayloadSize > MaxStanzaSize ->
|
|
||||||
{error, size_limit};
|
|
||||||
parse_request(Data, _PayloadSize, _MaxStanzaSize) ->
|
|
||||||
?DEBUG("--- incoming data --- ~n~s~n --- END --- ", [Data]),
|
?DEBUG("--- incoming data --- ~n~s~n --- END --- ", [Data]),
|
||||||
%% MR: I do not think it works if put put several elements in the
|
%% MR: I do not think it works if put put several elements in the
|
||||||
%% same body:
|
%% same body:
|
||||||
@ -1103,7 +1108,12 @@ parse_request(Data, _PayloadSize, _MaxStanzaSize) ->
|
|||||||
end
|
end
|
||||||
end, Els),
|
end, Els),
|
||||||
Sid = xml:get_attr_s("sid",Attrs),
|
Sid = xml:get_attr_s("sid",Attrs),
|
||||||
{ok, {Sid, Rid, Attrs, FixedEls}}
|
if
|
||||||
|
PayloadSize =< MaxStanzaSize ->
|
||||||
|
{ok, {Sid, Rid, Attrs, FixedEls}};
|
||||||
|
true ->
|
||||||
|
{size_limit, Sid}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
{xmlelement, _Name, _Attrs, _Els} ->
|
{xmlelement, _Name, _Attrs, _Els} ->
|
||||||
|
Loading…
Reference in New Issue
Block a user