INETS-How to handle redirection

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


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

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

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


Sanjaya Vitharana

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

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

Eshell V5.4.8  (abort with ^G)
1> dbg:tracer().
2> dbg:p(all, [call]).
3> dbg:tpl(httpc_response, redirect, [{'_', [], [{return_trace}]}]).
--------------------Request to Redirected 
4> URL3="".
5> http:request(get, {URL3, []}, [{timeout, 10000},{autoredirect, 

=INFO REPORT==== 19-Sep-2005::16:26:23 ===
The inets application was not started. Has now been started as a temporary 
6> http:request(get, {URL3, []}, [{timeout, 10000},{autoredirect, 
--------------------Request to NON Redirected 
7> URL2="".
8> http:request(get, {URL2, []}, [{timeout, 10000},{autoredirect, 
      {"date","Mon, 19 Sep 2005 10:25:26 GMT"},
       "Apache/2.0.52 (Unix) mod_ssl/2.0.52 OpenSSL/0.9.7a DAV/2 
      {"last-modified","Sun, 18 Sep 2005 17:32:01 GMT"},
      {"keep-alive","timeout=15, max=100"}],
     "<?xml version='1.0' 
ent>\n<key no=\"1\"></key>\n<key 

----- 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
>> the PHP Script redirect it to
>> 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