Blob Blame History Raw
Generates a human-readable XHTML page which is returned
when a user tries to browse the HTTP-poll URL configured
for the server (a common mistake).

This issue is tracked in EJAB-1106.

This changeset was introduced in revision 2751,
branch http://svn.process-one.net/ejabberd/branches/ejabberd-2.1.x

The first stable version containing the fix is 2.1.1.

--- a/src/web/ejabberd_http_poll.erl	(revision 2750)
+++ b/src/web/ejabberd_http_poll.erl	(revision 2751)
@@ -154,12 +154,32 @@
 		    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;
 process(_, _Request) ->
     {400, [], {xmlelement, "h1", [],
 	       [{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
 %%%----------------------------------------------------------------------
--- a/src/web/mod_http_bind.erl	(revision 2750)
+++ b/src/web/mod_http_bind.erl	(revision 2751)
@@ -69,7 +69,14 @@
     ejabberd_http_bind:process_request(Data, IP);
 process([], #request{method = 'GET',
                      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, "head", [],
        [{xmlelement, "title", [], [{xmlcdata, Heading}]}]},
@@ -77,15 +84,15 @@
        [{xmlelement, "h1", [], [{xmlcdata, Heading}]},
         {xmlelement, "p", [],
          [{xmlcdata, "An implementation of "},
-          {xmlelement, "a", [{"href", "http://www.xmpp.org/extensions/xep-0206.html"}],
-           [{xmlcdata, "XMPP over BOSH (XEP-0206)"}]}]}
-       ]}]};
-process(_Path, _Request) ->
-    ?DEBUG("Bad Request: ~p", [_Request]),
-    {400, [], {xmlelement, "h1", [],
-	       [{xmlcdata, "400 Bad Request"}]}}.
+          {xmlelement, "a",
+	   [{"href", "http://xmpp.org/extensions/xep-0206.html"}],
+           [{xmlcdata, "XMPP over BOSH (XEP-0206)"}]}]},
+        {xmlelement, "p", [],
+         [{xmlcdata, "This web page is only informative. "
+	   "To use HTTP-Bind you need a Jabber/XMPP client that supports it."}
+	 ]}
+       ]}]}.
 
-
 %%%----------------------------------------------------------------------
 %%% BEHAVIOUR CALLBACKS
 %%%----------------------------------------------------------------------