browsers behaviour towards yaws http redirect - unclear

MEENA SELVAM <>
Thu Jul 21 06:11:28 CEST 2005


The redirect below adds a "Location:" header to the
responce headers to the Browser. The Browser then
displays the new page as indicated in the "Location"
header.

out(_Arg) ->
   
L="http://www.google.com/search?num=20&hl=en&lr=lang_en%7Clang_sv&q=yaws",
    {redirect, L}.

What other things can replace L in the
{redirect, L}.

Is there any other list of values that can be passed
along with redirect? Ie what are the other forms of
redirect return values?

In my situation, the code was written by someone
else.. the redirection occurs as expected, that is the
redirected page contents are displayed in the browser,
but still the address field in the browser is same as
the original uri.

What is controlling the address field of the
redirected page. Does the browser look into the http
response headers to decide on this or it is designed
to put the original uri itself ? Ideally it should put
the location as the address field ? am I right?


Or is it possible, because a proxy is involved, 
deliberately the redirected uri is deliberately hidden
from the http client? In other words, can there be any
motive for such a thing .. ie browser still sticking
on to old uri?

Possibility  2:

Again, in my situation, the redirection is done at dns
level also. It is quite possible that the browser gets
back the redirected uri / ip as part of the dns
response (custom dns server is designed to do this.
That is any URI, in the browser is resolved to a fixed
ip address). If this is the case, the browser will
send a http-request to the new ip 47.80.18.95. a yaws
webserver is running in this host and listening to
http requests. So the index page is displayed in the
browser correctly. But the address field is still the
old, say www.msn.com

So when is there a possibility that a http request
(which is just after a dns manipulation) is serviced
correctly to the extent, the proper page is displayed,
but with a flaw namely the address field remains to be
the old one before the dns lookup?

 In both possibilities, is this  a browser issue?  
Or is it something to do with the redirect at the web
server . In the web server code, redirects are
involved.

The code is as follows:

we have a captive portal module which is dns based
redirection of all uri to a fixed ip.

%% This is for the WSS captive portal redirect server
(listening on port 8888)
captive_redirect(A) ->
    O = A#arg.opaque,
    RedirUrl = O#rdir_opaque.redir_url,
    OrigArg = A#arg{ req = O#rdir_opaque.orig_req },
    OrigUrlTmp = yaws_api:request_url(OrigArg),
    OrigUrl = lists:flatten(
		yaws_api:format_url(OrigUrlTmp#url{port =
undefined})),
    
    Vars =
	[{"url", OrigUrl},
	 {"host", (A#arg.headers)#headers.host},
	 {"path", begin
		      {abs_path, P} =
			  (O#rdir_opaque.orig_req)#http_request.path,
                      P
		  end},
	 {"method",
atom_to_list((O#rdir_opaque.orig_req)#http_request.method)}
	],
    [{redirect, expand_link_href_vb(RedirUrl, Vars,
A)}].


expand_link_href_vb(Str, Vars, A) ->
    expand_link_href_vb(Str, Vars, A, true).

expand_link_href_vb([], _, _,_) -> [];
expand_link_href_vb(["<var:"++VarX | T], Vars, A,
UrlEncodeP) ->
    Var = string:strip(VarX, right, $>),
    case lists:keysearch(Var, 1, Vars) of
	{value, {_, Val}} when UrlEncodeP == true ->
	    [yaws_api:url_encode(Val) |
	     expand_link_href_vb(T, Vars, A, UrlEncodeP)];
	{value, {_, Val}} ->
	    [Val | expand_link_href_vb(T, Vars, A,
UrlEncodeP)];
	_ ->
	    ["<var:"++VarX | expand_link_href_vb(T, Vars, A,
UrlEncodeP)]
    end;
expand_link_href_vb([H|T], Vars, A, UrlEncodeP) ->
    [H|expand_link_href_vb(T, Vars, A, UrlEncodeP)].


                                



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the erlang-questions mailing list