24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-26 22:35:31 +02:00

Show informative webpage when browsing the HTTP-Poll page (EJAB-1106)

SVN Revision: 2751
This commit is contained in:
Badlop 2009-11-23 15:21:05 +00:00
parent 7fd3d67ff3
commit 58425ba45d
2 changed files with 37 additions and 10 deletions

View File

@ -154,12 +154,32 @@ process([], #request{data = Data,
end end
end; end;
_ -> _ ->
{200, [?CT, {"Set-Cookie", "ID=-2:0; expires=-1"}], ""} HumanHTMLxmlel = get_human_html_xmlel(),
{200, [?CT, {"Set-Cookie", "ID=-2:0; expires=-1"}], HumanHTMLxmlel}
end; end;
process(_, _Request) -> process(_, _Request) ->
{400, [], {xmlelement, "h1", [], {400, [], {xmlelement, "h1", [],
[{xmlcdata, "400 Bad Request"}]}}. [{xmlcdata, "400 Bad Request"}]}}.
%% Code copied from mod_http_bind.erl and customized
get_human_html_xmlel() ->
Heading = "ejabberd " ++ atom_to_list(?MODULE),
{xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"}],
[{xmlelement, "head", [],
[{xmlelement, "title", [], [{xmlcdata, Heading}]}]},
{xmlelement, "body", [],
[{xmlelement, "h1", [], [{xmlcdata, Heading}]},
{xmlelement, "p", [],
[{xmlcdata, "An implementation of "},
{xmlelement, "a",
[{"href", "http://xmpp.org/extensions/xep-0025.html"}],
[{xmlcdata, "Jabber HTTP Polling (XEP-0025)"}]}]},
{xmlelement, "p", [],
[{xmlcdata, "This web page is only informative. "
"To use HTTP-Poll you need a Jabber/XMPP client that supports it."}
]}
]}]}.
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% Callback functions from gen_fsm %%% Callback functions from gen_fsm
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------

View File

@ -69,7 +69,14 @@ process([], #request{method = 'POST',
ejabberd_http_bind:process_request(Data, IP); ejabberd_http_bind:process_request(Data, IP);
process([], #request{method = 'GET', process([], #request{method = 'GET',
data = []}) -> data = []}) ->
Heading = "Ejabberd " ++ atom_to_list(?MODULE) ++ " v" ++ ?MOD_HTTP_BIND_VERSION, get_human_html_xmlel();
process(_Path, _Request) ->
?DEBUG("Bad Request: ~p", [_Request]),
{400, [], {xmlelement, "h1", [],
[{xmlcdata, "400 Bad Request"}]}}.
get_human_html_xmlel() ->
Heading = "ejabberd " ++ atom_to_list(?MODULE) ++ " v" ++ ?MOD_HTTP_BIND_VERSION,
{xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"}], {xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"}],
[{xmlelement, "head", [], [{xmlelement, "head", [],
[{xmlelement, "title", [], [{xmlcdata, Heading}]}]}, [{xmlelement, "title", [], [{xmlcdata, Heading}]}]},
@ -77,14 +84,14 @@ process([], #request{method = 'GET',
[{xmlelement, "h1", [], [{xmlcdata, Heading}]}, [{xmlelement, "h1", [], [{xmlcdata, Heading}]},
{xmlelement, "p", [], {xmlelement, "p", [],
[{xmlcdata, "An implementation of "}, [{xmlcdata, "An implementation of "},
{xmlelement, "a", [{"href", "http://www.xmpp.org/extensions/xep-0206.html"}], {xmlelement, "a",
[{xmlcdata, "XMPP over BOSH (XEP-0206)"}]}]} [{"href", "http://xmpp.org/extensions/xep-0206.html"}],
]}]}; [{xmlcdata, "XMPP over BOSH (XEP-0206)"}]}]},
process(_Path, _Request) -> {xmlelement, "p", [],
?DEBUG("Bad Request: ~p", [_Request]), [{xmlcdata, "This web page is only informative. "
{400, [], {xmlelement, "h1", [], "To use HTTP-Bind you need a Jabber/XMPP client that supports it."}
[{xmlcdata, "400 Bad Request"}]}}. ]}
]}]}.
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% BEHAVIOUR CALLBACKS %%% BEHAVIOUR CALLBACKS