summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMickaël Rémond <mickael.remond@process-one.net>2006-06-02 15:02:39 +0000
committerMickaël Rémond <mickael.remond@process-one.net>2006-06-02 15:02:39 +0000
commit05c50cc5caeda5133321862b46f39db36e93a694 (patch)
treef12e1142759cb35d1b975a5ecacfa9ac1f898154 /src
parent* src/web/ejabberd_http_poll.erl: Messages polled between the (diff)
* src/web/ejabberd_http.erl: The web module now accepts HTTP
absolute URL (used behind a proxy). This apply to HTTP polling and to the web interface (Thanks to Jean-Sebastien Pedron). SVN Revision: 576
Diffstat (limited to 'src')
-rw-r--r--src/web/ejabberd_http.erl31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/web/ejabberd_http.erl b/src/web/ejabberd_http.erl
index f51b02e6..5113f1af 100644
--- a/src/web/ejabberd_http.erl
+++ b/src/web/ejabberd_http.erl
@@ -133,13 +133,17 @@ process_header(State, Data) ->
SockMod = State#state.sockmod,
Socket = State#state.socket,
case Data of
- {ok, {http_request, Method, Path, Version}} ->
+ {ok, {http_request, Method, Uri, Version}} ->
KeepAlive = case Version of
{1, 1} ->
true;
_ ->
false
end,
+ Path = case Uri of
+ {absoluteURI, _Scheme, _Host, _Port, P} -> {abs_path, P};
+ _ -> Uri
+ end,
State#state{request_method = Method,
request_version = Version,
request_path = Path,
@@ -716,10 +720,27 @@ parse_req(Line) ->
"*" ->
% Is this correct?
"*";
- P ->
- % FIXME: Handle
- % absolute URIs
- {abs_path, P}
+ _ ->
+ case string:str(URI, "://") of
+ 0 ->
+ % Relative URI
+ % ex: /index.html
+ {abs_path, URI};
+ N ->
+ % Absolute URI
+ % ex: http://localhost/index.html
+
+ % Remove scheme
+ % ex: URI2 = localhost/index.html
+ URI2 = string:substr(URI, N + 3),
+ % Look for the start of the path
+ % (or the lack of a path thereof)
+ case string:chr(URI2, $/) of
+ 0 -> {abs_path, "/"};
+ M -> {abs_path,
+ string:substr(URI2, M + 1)}
+ end
+ end
end,
case VersionStr of
[] ->