Is it possible to add custom HTTP headers in mod_http_fileserver ?
I saw that a cache header has been implemented but it will be great if I could define more custom headers in the ejabberd config files.
To access the most up-to-date ejabberd documentation, please visit docs.ejabberd.im »
Is it possible to add custom HTTP headers in mod_http_fileserver ?
I saw that a cache header has been implemented but it will be great if I could define more custom headers in the ejabberd config files.
That feature is not
That feature is not supported.
But you can easily modify the source code:
Where should I add it? Is
Where should I add it?
Is there a chance it'll be supported in the future?
Patch included. Feature tracked. Why is interesting?
Where should I add it?
Here is a simple patch:
Index: src/web/mod_http_fileserver.erl
===================================================================
--- src/web/mod_http_fileserver.erl (revisiĆ³n: 554)
+++ src/web/mod_http_fileserver.erl (copia de trabajo)
@@ -72,6 +72,8 @@
{200,
[{"Server", "ejabberd"},
{"Last-Modified", last_modified(FileName)},
+ {"X-Custom-1", "test 1"},
+ {"X-Custom-2", "test 2"},
{"Content-type", content_type(FileName)}],
FileContents};
{error, Error} ->
Is there a chance it'll be supported in the future?
I've reported the feature request:
Custom HTTP headers in mod_http_fileserver .
Why is this feature interesting? Why adding custom HTTP headers in the response?
This is interesting because
This is interesting because I'm trying to leverage the new FF3 and IE8 cross domain Ajax.
With your code I have to set the same headers to all the requests.
Can I implement it inside a costum module that use the fileserver api?
For example, can I use it inside the http-bind module?
Thanks
Yes, you can modify
Yes, you can modify ejabberd_http_bind.erl and add any custom HTTP headers you want.
I don't know if you are interested in this, but it could be implemented to return specific HTTP response headers depending in the HTTP request headers. For example, if UserAgent contains XX, then add this response header: "X-Custom: YY".
works great. I still think
works great.
I still think it will be useful to be able to set custom headers in the config file but my problem is solved for now.
During my research I found that the function "element_to_string" and the next few functions defined in ejabberd_http.erl
are also defined in xml.erl. Is there a reason for the code duplication?
In mod_http_fileserver.erl in the content_type(Filename) -> function I didn't see a content type for javascript . Is it missing or is it ok?
Thanks.
Content type of .js
During my research I found that the function "element_to_string" and the next few functions defined in ejabberd_http.erl
are also defined in xml.erl. Is there a reason for the code duplication?
I remember the same question is in the ejabberd mailing list. Alexey Shchepin explained that crypt(S) is not exactly equal: there is a slight difference. The problem is that some browsers have problem with some encryption, so the code was duplicated from XML and adapted for HTTP requirements.
In mod_http_fileserver.erl in the content_type(Filename) -> function I didn't see a content type for javascript . Is it missing or is it ok?
Well, I guess it is missing and could be added. What is the content type of ".js" ?
The content type of .js is
The content type of .js is application/x-javascript as far as I know. Just checked on firebug.
About the first issue, sorry I'm reading the mailing list but didn't notice Alexey response.
The more I'm digging into ejabberd and it's file server the more I'm impressed with the possibilities.
Thanks
Added js content type
The content type of .js is application/x-javascript as far as I know. Just checked on firebug.
Ok, added to SVN.
About the first issue, sorry I'm reading the mailing list but didn't notice Alexey response.
Sorry, I didn't explain correctly: I recently read the email with the question, so I asked Alexey, and I replied in the mailing list with his response. Then I told you in this forum :)
I also need it. Where do I
I also need it.
Where do I add the above code?