INETS-How to handle redirection

Sanjaya Vitharana <>
Tue Sep 20 05:04:03 CEST 2005


Hi...!!!

Many thanks for your quick reply, I have tried with {autoredirect, false}, 
but it fails.

dbg:tracer().
dbg:p(all, [call]).
dbg:tpl(httpc_response, redirect, [{'_', [], [{return_trace}]}]).


I exactly don't know how to handle above 3 commands (where can I found how 
to use the above commands?).

Anyhow what I did is just use this 3 command in erlang emulator window and 
made the http request in the same window. Below I'll copy the full steps 
that I followed. Kindly refer & inform if I am doing anything wrong, so I 
can give you the exact result what you need.

Only chnage that I have made comparing with my implemented code is, i have 
change the Asynchronous request to Synchronous when I use the erlang
emulator.

Furthermore, PHP page has only 1 redirection, & working with the web browser 
(IE) without any problem

Regards,

Sanjaya Vitharana

--------------------full steps that I 
followed-----------------------------------------

Erlang (BEAM) emulator version 5.4.8 [threads:0]

Eshell V5.4.8  (abort with ^G)
1> dbg:tracer().
{ok,<0.32.0>}
2> dbg:p(all, [call]).
{ok,[{,25}]}
3> dbg:tpl(httpc_response, redirect, [{'_', [], [{return_trace}]}]).
{ok,[{,1},{saved,1}]}
--------------------Request to Redirected 
Page-----------------------------------------
4> URL3="http://scr.int/vm/dialout.php?key=c&session=abc".
"http://scr.int/vm/dialout.php?key=c&session=abc"
5> http:request(get, {URL3, []}, [{timeout, 10000},{autoredirect, 
false}],[]).

=INFO REPORT==== 19-Sep-2005::16:26:23 ===
The inets application was not started. Has now been started as a temporary 
appli
cation.
{error,timeout}
6> http:request(get, {URL3, []}, [{timeout, 10000},{autoredirect, 
false}],[]).
{error,timeout}
--------------------Request to NON Redirected 
Page--------------------------------------
7> URL2="http://scr.int/vm/index2.xml?key=c&session=abc".
"http://scr.int/vm/index2.xml?key=c&session=abc"
8> http:request(get, {URL2, []}, [{timeout, 10000},{autoredirect, 
false}],[]).
{ok,{{"HTTP/1.1",200,"OK"},
     [{"connection","Keep-Alive"},
      {"date","Mon, 19 Sep 2005 10:25:26 GMT"},
      {"etag","\"112ee7-14a-34558640\""},
      {"server",
       "Apache/2.0.52 (Unix) mod_ssl/2.0.52 OpenSSL/0.9.7a DAV/2 
PHP/5.0.3"},
      {"content-length","330"},
      {"content-type","application/xml"},
      {"last-modified","Sun, 18 Sep 2005 17:32:01 GMT"},
      {"accept-ranges","bytes"},
      {"keep-alive","timeout=15, max=100"}],
     "<?xml version='1.0' 
encoding='ISO-8859-1'?>\n<IVR>\n<!--<content>/vms/news
1.vox</content>-->\n<content>/vms/73.vox</content>\n<content>/vms/1234.vox</cont
ent>\n<key no=\"1\">http://192.168.248.27/vm/index2.xml</key>\n<key 
no=\"2\">htt
p://192.168.248.27/vm/connect.xml</key>\n<session 
mvfwd=\"1\">304901077501446820
01126528157</session>\n</IVR>\n"}}
9>
----------------------------------------------------------------------------------------------


----- Original Message ----- 
From: "Ingela Anderton" <>
To: <>
Cc: <>
Sent: Monday, September 19, 2005 1:56 PM
Subject: Re: INETS-How to handle redirection


> Sanjaya Vitharana wrote:
>> Hi...!!!
>>
>> Can any body help me to handle the get request in inets when REDIRECTION 
>> done by the PHP script. (or any other script in websever) ???
>>
>> i.e.
>> when get request made to below page
>> http://scr.int/vm/dialout.php?key=c&session=abc
>>
>> the PHP Script redirect it to
>> http://scr.int/vm/index2.xml?key=c&session=abc
>>
>> this is working on the web browser without any problem.
>>
>> But my inets client don't get any reply for the same request & time out 
>> happens.
>>
>> all other requests are working, but when redirection on the PHP Script 
>> inets don't get any reply from web serer, i tried with increasing 
>> timeout, but it also fails. may be when redirection on the Script there 
>> will be any other way to handle it in inets.
>>
>> I'm using
>>
>> handle_info({http, {RequestId, Result}}, State) ->
>>
>> to catch the webserver reply & and request type is Asynchronous.
>>
>> Need help from to handle the redirection properly in inets???
> Have you tried setting the option {autoredirect, false}? Do you get
> the redirect answer then? The intes client will automaticly try to
> redirect the request. If it gets a redirect more than four times
> in a row it should give up.
>
> You could try the following trace commands to get some more info
> about what happens. (If it does not seem to be what is expected
> you can send me the printouts and I will look at them.)
> dbg:tracer()
> dbg:p(all, [call]).
> dbg:tpl(httpc_response, redirect, [{'_', [], [{return_trace}]}]).
>
> -- 
> /Ingela - OTP team
>
>
>
>
>
> 





More information about the erlang-questions mailing list