[ejabberd] return a string from HTTP request handlers

Badlop badlop at gmail.com
Fri May 30 23:13:43 MSD 2008


On Wed, Apr 30, 2008 at 12:04 PM, mark peleus <mark.peleus at gmail.com> wrote:
> In the example:
> http://www.process-one.net/en/wiki/ejabberd_HTTP_request_handlers/
> the module returns HTML document.
>
> process(_LocalPath = ["world"], _Request) ->
>     {xmlelement, "html", [{"xmlns",...
>
> Is it possible to return a string instead of xml?

Yes, for example this function clause:

-------------
process(["string"], _Request) ->
    {200, [{"X-Custom", "test-7"}], "This is a string."};
-------------


When requested produces:

------------
$ lynx -mime_header http://localhost:5280/hello/string
HTTP/1.0 200 OK
Connection: close
Content-Type: text/html; charset=utf-8
Content-Length: 17
X-Custom: test-7

This is a string.
----------


> Which module converts the all the xmlelements to the HTML document?

ejabberd_http says:
-------
   case process(RequestHandlers, Request) of
		El when element(1, El) == xmlelement ->
		    make_xhtml_output(State, 200, [], El);
-------


More information about the ejabberd mailing list