mirror of
https://github.com/processone/ejabberd.git
synced 2025-01-03 18:02:28 +01:00
* src/web/ejabberd_http.erl: "Connection:" header value now
matched case-insensitive, and returned to client, replaced duplicate is_space($\r) with is_space($\t) (thanks to Maxim Ryazanov) SVN Revision: 353
This commit is contained in:
parent
9f27556a01
commit
94ed3740d9
@ -1,3 +1,10 @@
|
|||||||
|
2005-05-23 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/web/ejabberd_http.erl: "Connection:" header value now
|
||||||
|
matched case-insensitive, and returned to client, replaced
|
||||||
|
duplicate is_space($\r) with is_space($\t) (thanks to Maxim
|
||||||
|
Ryazanov)
|
||||||
|
|
||||||
2005-05-21 Alexey Shchepin <alexey@sevcom.net>
|
2005-05-21 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/mod_pubsub/mod_pubsub.erl: Fixed XML element name for
|
* src/mod_pubsub/mod_pubsub.erl: Fixed XML element name for
|
||||||
|
@ -139,7 +139,7 @@ process_header(State, Data) ->
|
|||||||
request_path = Path,
|
request_path = Path,
|
||||||
request_keepalive = KeepAlive};
|
request_keepalive = KeepAlive};
|
||||||
{ok, {http_header, _, 'Connection', _, Conn}} ->
|
{ok, {http_header, _, 'Connection', _, Conn}} ->
|
||||||
KeepAlive1 = case Conn of
|
KeepAlive1 = case jlib:tolower(Conn) of
|
||||||
"keep-alive" ->
|
"keep-alive" ->
|
||||||
true;
|
true;
|
||||||
"close" ->
|
"close" ->
|
||||||
@ -194,7 +194,7 @@ process_request(#state{request_method = 'GET',
|
|||||||
request_auth = Auth,
|
request_auth = Auth,
|
||||||
request_lang = Lang,
|
request_lang = Lang,
|
||||||
use_http_poll = UseHTTPPoll,
|
use_http_poll = UseHTTPPoll,
|
||||||
use_web_admin = UseWebAdmin}) ->
|
use_web_admin = UseWebAdmin} = State) ->
|
||||||
US = case Auth of
|
US = case Auth of
|
||||||
{SJID, P} ->
|
{SJID, P} ->
|
||||||
case jlib:string_to_jid(SJID) of
|
case jlib:string_to_jid(SJID) of
|
||||||
@ -214,6 +214,7 @@ process_request(#state{request_method = 'GET',
|
|||||||
case US of
|
case US of
|
||||||
unauthorized ->
|
unauthorized ->
|
||||||
make_xhtml_output(
|
make_xhtml_output(
|
||||||
|
State,
|
||||||
401,
|
401,
|
||||||
[{"WWW-Authenticate", "basic realm=\"ejabberd\""}],
|
[{"WWW-Authenticate", "basic realm=\"ejabberd\""}],
|
||||||
ejabberd_web:make_xhtml([{xmlelement, "h1", [],
|
ejabberd_web:make_xhtml([{xmlelement, "h1", [],
|
||||||
@ -238,15 +239,15 @@ process_request(#state{request_method = 'GET',
|
|||||||
case ejabberd_web:process_get({UseHTTPPoll, UseWebAdmin},
|
case ejabberd_web:process_get({UseHTTPPoll, UseWebAdmin},
|
||||||
Request) of
|
Request) of
|
||||||
El when element(1, El) == xmlelement ->
|
El when element(1, El) == xmlelement ->
|
||||||
make_xhtml_output(200, [], El);
|
make_xhtml_output(State, 200, [], El);
|
||||||
{Status, Headers, El} when
|
{Status, Headers, El} when
|
||||||
element(1, El) == xmlelement ->
|
element(1, El) == xmlelement ->
|
||||||
make_xhtml_output(Status, Headers, El);
|
make_xhtml_output(State, Status, Headers, El);
|
||||||
Text when is_list(Text) ->
|
Text when is_list(Text) ->
|
||||||
make_text_output(200, [], Text);
|
make_text_output(State, 200, [], Text);
|
||||||
{Status, Headers, Text} when
|
{Status, Headers, Text} when
|
||||||
is_list(Text) ->
|
is_list(Text) ->
|
||||||
make_text_output(Status, Headers, Text)
|
make_text_output(State, Status, Headers, Text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
@ -280,6 +281,7 @@ process_request(#state{request_method = 'POST',
|
|||||||
case US of
|
case US of
|
||||||
unauthorized ->
|
unauthorized ->
|
||||||
make_xhtml_output(
|
make_xhtml_output(
|
||||||
|
State,
|
||||||
401,
|
401,
|
||||||
[{"WWW-Authenticate", "basic realm=\"ejabberd\""}],
|
[{"WWW-Authenticate", "basic realm=\"ejabberd\""}],
|
||||||
ejabberd_web:make_xhtml([{xmlelement, "h1", [],
|
ejabberd_web:make_xhtml([{xmlelement, "h1", [],
|
||||||
@ -313,20 +315,20 @@ process_request(#state{request_method = 'POST',
|
|||||||
case ejabberd_web:process_get({UseHTTPPoll, UseWebAdmin},
|
case ejabberd_web:process_get({UseHTTPPoll, UseWebAdmin},
|
||||||
Request) of
|
Request) of
|
||||||
El when element(1, El) == xmlelement ->
|
El when element(1, El) == xmlelement ->
|
||||||
make_xhtml_output(200, [], El);
|
make_xhtml_output(State, 200, [], El);
|
||||||
{Status, Headers, El} when
|
{Status, Headers, El} when
|
||||||
element(1, El) == xmlelement ->
|
element(1, El) == xmlelement ->
|
||||||
make_xhtml_output(Status, Headers, El);
|
make_xhtml_output(State, Status, Headers, El);
|
||||||
Text when is_list(Text) ->
|
Text when is_list(Text) ->
|
||||||
make_text_output(200, [], Text);
|
make_text_output(State, 200, [], Text);
|
||||||
{Status, Headers, Text} when is_list(Text) ->
|
{Status, Headers, Text} when is_list(Text) ->
|
||||||
make_text_output(Status, Headers, Text)
|
make_text_output(State, Status, Headers, Text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
|
|
||||||
process_request(_) ->
|
process_request(State) ->
|
||||||
make_xhtml_output(
|
make_xhtml_output(State,
|
||||||
400,
|
400,
|
||||||
[],
|
[],
|
||||||
ejabberd_web:make_xhtml([{xmlelement, "h1", [],
|
ejabberd_web:make_xhtml([{xmlelement, "h1", [],
|
||||||
@ -353,7 +355,7 @@ recv_data(State, Len, Acc) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
make_xhtml_output(Status, Headers, XHTML) ->
|
make_xhtml_output(State, Status, Headers, XHTML) ->
|
||||||
Data = case lists:member(html, Headers) of
|
Data = case lists:member(html, Headers) of
|
||||||
true ->
|
true ->
|
||||||
list_to_binary([?HTML_DOCTYPE,
|
list_to_binary([?HTML_DOCTYPE,
|
||||||
@ -371,16 +373,32 @@ make_xhtml_output(Status, Headers, XHTML) ->
|
|||||||
{"Content-Length", integer_to_list(size(Data))} |
|
{"Content-Length", integer_to_list(size(Data))} |
|
||||||
Headers]
|
Headers]
|
||||||
end,
|
end,
|
||||||
|
HeadersOut = case {State#state.request_version,
|
||||||
|
State#state.request_keepalive} of
|
||||||
|
{{1, 1}, true} -> Headers1;
|
||||||
|
{_, true} ->
|
||||||
|
[{"Connection", "keep-alive"} | Headers1];
|
||||||
|
{_, false} ->
|
||||||
|
% not required for http versions < 1.1
|
||||||
|
% but would make no harm
|
||||||
|
[{"Connection", "close"} | Headers1]
|
||||||
|
end,
|
||||||
|
|
||||||
|
Version = case State#state.request_version of
|
||||||
|
{1, 1} -> "HTTP/1.1 ";
|
||||||
|
_ -> "HTTP/1.0 "
|
||||||
|
end,
|
||||||
|
|
||||||
H = lists:map(fun({Attr, Val}) ->
|
H = lists:map(fun({Attr, Val}) ->
|
||||||
[Attr, ": ", Val, "\r\n"];
|
[Attr, ": ", Val, "\r\n"];
|
||||||
(_) ->
|
(_) ->
|
||||||
[]
|
[]
|
||||||
end, Headers1),
|
end, HeadersOut),
|
||||||
SL = ["HTTP/1.1 ", integer_to_list(Status), " ",
|
SL = [Version, integer_to_list(Status), " ",
|
||||||
code_to_phrase(Status), "\r\n"],
|
code_to_phrase(Status), "\r\n"],
|
||||||
[SL, H, "\r\n", Data].
|
[SL, H, "\r\n", Data].
|
||||||
|
|
||||||
make_text_output(Status, Headers, Text) ->
|
make_text_output(State, Status, Headers, Text) ->
|
||||||
Data = list_to_binary(Text),
|
Data = list_to_binary(Text),
|
||||||
Headers1 = case lists:keysearch("Content-Type", 1, Headers) of
|
Headers1 = case lists:keysearch("Content-Type", 1, Headers) of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
@ -391,10 +409,27 @@ make_text_output(Status, Headers, Text) ->
|
|||||||
{"Content-Length", integer_to_list(size(Data))} |
|
{"Content-Length", integer_to_list(size(Data))} |
|
||||||
Headers]
|
Headers]
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
HeadersOut = case {State#state.request_version,
|
||||||
|
State#state.request_keepalive} of
|
||||||
|
{{1, 1}, true} -> Headers1;
|
||||||
|
{_, true} ->
|
||||||
|
[{"Connection", "keep-alive"} | Headers1];
|
||||||
|
{_, false} ->
|
||||||
|
% not required for http versions < 1.1
|
||||||
|
% but would make no harm
|
||||||
|
[{"Connection", "close"} | Headers1]
|
||||||
|
end,
|
||||||
|
|
||||||
|
Version = case State#state.request_version of
|
||||||
|
{1, 1} -> "HTTP/1.1 ";
|
||||||
|
_ -> "HTTP/1.0 "
|
||||||
|
end,
|
||||||
|
|
||||||
H = lists:map(fun({Attr, Val}) ->
|
H = lists:map(fun({Attr, Val}) ->
|
||||||
[Attr, ": ", Val, "\r\n"]
|
[Attr, ": ", Val, "\r\n"]
|
||||||
end, Headers1),
|
end, HeadersOut),
|
||||||
SL = ["HTTP/1.1 ", integer_to_list(Status), " ",
|
SL = [Version, integer_to_list(Status), " ",
|
||||||
code_to_phrase(Status), "\r\n"],
|
code_to_phrase(Status), "\r\n"],
|
||||||
[SL, H, "\r\n", Data].
|
[SL, H, "\r\n", Data].
|
||||||
|
|
||||||
@ -779,7 +814,7 @@ is_space($\r) ->
|
|||||||
true;
|
true;
|
||||||
is_space($\n) ->
|
is_space($\n) ->
|
||||||
true;
|
true;
|
||||||
is_space($\r) ->
|
is_space($\t) ->
|
||||||
true;
|
true;
|
||||||
is_space(_) ->
|
is_space(_) ->
|
||||||
false.
|
false.
|
||||||
|
Loading…
Reference in New Issue
Block a user